-
-
Save rootmos/a6ffe3d07f766dcaa1318a875d9d1c6f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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