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

14 lines
325 B
Plaintext
Raw Normal View History

-- 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)