1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-30 02:52:59 +03:00
juvix/examples/milestone/Fibonacci/Fibonacci.juvix

14 lines
268 B
Plaintext
Raw Normal View History

module Fibonacci;
import Stdlib.Prelude open;
fib : Nat → Nat → Nat → Nat;
fib zero x1 _ := x1;
fib (suc n) x1 x2 := fib n x2 (x1 + x2);
fibonacci : Nat → Nat;
fibonacci n := fib n 0 1;
main : IO;
main := readLn (printNatLn ∘ fibonacci ∘ stringToNat);