RosettaCodeData/Task/Anonymous-recursion/OCaml/anonymous-recursion-1.ml
2024-10-16 18:07:41 -07:00

10 lines
154 B
OCaml

let fib n =
let rec real = function
0 -> 1
| 1 -> 1
| n -> real (n-1) + real (n-2)
in
if n < 0 then
None
else
Some (real n)