Fib := proc( n :: nonnegint ) proc( k ) option remember; # automatically memoise if k = 0 then 0 elif k = 1 then 1 else # Recurse, anonymously thisproc( k - 1 ) + thisproc( k - 2 ) end end( n ) end proc: