~starkingdoms/starkingdoms

ref: e3dc9c372e5372aaca738c2346313a626530fa25 starkingdoms/crates/kabel/test/runtime/recursive_fib.kab -rw-r--r-- 220 bytes
e3dc9c37 — core Revert "netcode: part updates (mystery performance issue, probably related to lots of malloc())" 8 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