Files
Fig/Tools/SpeedTest/fibLoopTest.fig
2025-12-19 20:38:40 +08:00

24 lines
475 B
Plaintext

var callCnt:Int = 0;
fun fib(x:Int) -> Int
{
callCnt = callCnt + 1;
if (x <= 1)
{
return x;
}
return fib(x-1) + fib(x-2);
}
var fibx:Int;
__fstdout_print("input an index of fib ");
fibx = __fvalue_int_parse(__fstdin_read());
var cnt:Int = 0;
__fstdout_println("test forever");
while (true)
{
cnt = cnt + 1;
__fstdout_println("test ", cnt,",result: ", fib(fibx));
__fstdout_println("func `fib` called ", callCnt);
callCnt = 0;
}