rf-web/vendor/bundle/gems/rouge-3.12.0/lib/rouge/demos/mathematica

9 lines
213 B
Plaintext
Raw Normal View History

2019-10-21 08:18:17 +00:00
(* Fibonacci numbers with memoization *)
fib::usage = "f[n] calculates the n'th Fibonacci number.";
fib[0] = fib[1] = 1;
fib[n_Integer?Positive]:= fib[n] = fib[n-1] + fib[n-2];
In[4]:= fib[42]
Out[4]= 433494437