Files
Fig-TreeWalker/ExampleCodes/SpeedTest/fibLoopTest.fig
PuqiAR c93840af5f
Some checks failed
Release Build / build-linux-x64 (push) Failing after 26s
Release Build / build-windows-x64 (push) Failing after 34s
[VER] v0.3.6-alpha
[Feat] 增加控制台在线安装器 !
[Impl] 修改ExampleCodes的一些实现,使用最新库 std.io
2026-01-04 00:51:11 +08:00

27 lines
473 B
Plaintext

import std.io;
import std.value;
var callCnt:Int = 0;
func fib(x:Int) -> Int
{
callCnt = callCnt + 1;
if (x <= 1)
{
return x;
}
return fib(x-1) + fib(x-2);
}
var fibx:Int;
io.print("input an index of fib ");
fibx = value.int_parse(io.read());
var cnt:Int = 0;
io.println("test forever");
while (true)
{
cnt = cnt + 1;
io.println("test ", cnt,",result: ", fib(fibx));
io.println("func `fib` called ", callCnt);
callCnt = 0;
}