Skip to content

Instantly share code, notes, and snippets.

@rootmos

rootmos/fib.ml Secret

Created Jun 6, 2017
Embed
What would you like to do?
let rec fib = function
| 1 -> 1
| 2 -> 1
| n -> (fib (n-1)) + (fib (n-2))
let () = print_int (fib 45); print_endline ""
(* > ocamlopt -o fib-ml fib.ml; /usr/bin/time ./fib-ml
* 1134903170
* 3.97user 0.00system 0:03.98elapsed 99%CPU (0avgtext+0avgdata 1896maxresident)k
* 0inputs+0outputs (0major+110minor)pagefaults 0swaps
*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment