mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 22:58:20 +00:00

I made a light pass over the text. Switched the includes over to the new btest-include and adapted the other TEXT-EXECs a bit. Also includes more tweaking all over the Sphinx setup.
32 lines
648 B
Text
32 lines
648 B
Text
module Factor;
|
|
|
|
export {
|
|
redef enum Log::ID += { LOG };
|
|
|
|
type Info: record {
|
|
num: count &log;
|
|
factorial_num: count &log;
|
|
};
|
|
}
|
|
|
|
function factorial(n: count): count
|
|
{
|
|
if ( n == 0 )
|
|
return 1;
|
|
|
|
else
|
|
return ( n * factorial(n - 1) );
|
|
}
|
|
|
|
event bro_init()
|
|
{
|
|
Log::create_stream(LOG, [$columns=Info]);
|
|
}
|
|
|
|
event bro_done()
|
|
{
|
|
local numbers: vector of count = vector(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
|
|
for ( n in numbers )
|
|
Log::write( Factor::LOG, [$num=numbers[n],
|
|
$factorial_num=factorial(numbers[n])]);
|
|
}
|