Optimising Perl 6
sub fib-optimised-v2($n) { $n > 1 ?? fib-optimised-v2($n - 1) + fib-optimised-v2($n - 2) !! $n; } sub fib-optimised-v3 { if @_[0] > 1 { fib-optimised-v3(@_[0] - 1) + fib-optimised-v3(@_[0] - 2); } else { @_[0]; } }