Created
May 3, 2016 08:13
-
-
Save b4284/38e5eda863339ab75a487ac1e028ed2a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| (* #require "num";; *) | |
| let fib n = | |
| let rec helper n2 a b = | |
| if n2 = 1 then b else helper (n2 - 1) b (a + b) | |
| in helper n 0 1;; | |
| let fib_big n = | |
| let rec helper n2 a b = | |
| if n2 = 1 then b else helper (n2 - 1) b (Big_int.add_big_int a b) | |
| in helper n (Big_int.big_int_of_int 0) (Big_int.big_int_of_int 1);; | |
| let () = ignore @@ fib_big 1000000;; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment