I tried to write my own fib function that works for large numbers (over 50) and I had no luck. First I tried the obvious solution but that overflows way to quicly. my next solution was this
$fun fib(a:int, b:int, index:int) = if(index = 1) then
$ (a+b)
$ else
$ fib(b, (a+b), index - 1);
Unfortunatly this also overflows.
You need to take a look at the
IntInfmodule, which provides access to arbitrary precision integers.You can convert from
Int.inttoIntInf.intusingIntInf.fromInt.Note, for any operations you do on them, you have to use
IntInf.<operation>instead of theIntcounterpart. This includes things like addition and the likes.