1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-03 09:41:10 +03:00
juvix/tests/Core/benchmark/test002.jvc

14 lines
325 B
Plaintext

-- tail recursion: compute n-th Fibonacci number in O(n)
def fib' := \n \x \y if n = 0 then x else fib' (n - 1) y (x + y);
def fib := \n fib' n 0 1;
def writeLn := \x write x >> write "\n";
writeLn (fib 10) >>
writeLn (fib 100) >>
writeLn (fib 1000) >>
writeLn (fib 10000) >>
writeLn (fib 100000) >>
writeLn (fib 1000000)