Fibonacci sequence: Difference between revisions
→Better Recursive doesn't need Memoization: shorten...
GordonBGood (talk | contribs) (→{{header|Mathematica}} / {{header|Wolfram Language}}: simplification of more efficient recursive and iterative....) |
GordonBGood (talk | contribs) (→Better Recursive doesn't need Memoization: shorten...) |
||
Line 4,759:
<lang python>def fibFastRec(n):
▲ else: return fib(prv, prvprv + prv, c - 1)
However, although much faster and not requiring memory, the above code can only process to a limited 'n' due to the limit on stack recursion depth by Python; it is better to use the iterative approach above or the generative one below.
|