RosettaCodeData/Task/Anonymous-recursion/OCaml/anonymous-recursion-1.ocaml
Ingy döt Net d066446780 langs a-z
2013-04-10 22:43:41 -07:00

10 lines
154 B
Text

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)