Defines arithmetic operations on a custom data type, and then uses it to run the explicit formula without going via floating point - no rounding or truncation. Calculates the ten millionth fibonacci number in a few seconds (it has roughly two million digits).

sub fib {my$n=shift;return$nif$n<2;return fib($n-1)+ fib($n-2);}# returns F_n in a scalar context# returns all elements in the sequence up to F_n in a list context# only one recursive callsub fib {my($n)=@_;return(0)if($n==0);return(0,1)if($n==1);my@fib= fib($n-1);return(@fib,$fib[-1]+$fib[-2]);}