~starkingdoms/starkingdoms

ref: 2e1aa7be2e2829b9f15f99bbc851cf1768026f5a starkingdoms/crates/kabel/test/runtime/recursive_fib.kab -rw-r--r-- 220 bytes
2e1aa7be — core feat: solver optimization (pro tip: do not do io in the hot path) 20 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
function fib(x) {
    if(x == 0) {
        return 0;
    }
    if(x == 1 || x == 2) {
        return 1;
    }
    return fib(x-1) + fib(x-2);
}
print fib(2); // 1
print fib(3); // 2
print fib(4); // 3
print fib(5); // 5