Fibonacci sequence: Difference between revisions
Content deleted Content added
No edit summary |
Added EchoLisp |
||
Line 2,213:
(This version defines <tt>fib(0) = 0</tt> because [http://www.research.att.com/~njas/sequences/A000045 OEIS A000045] does.)
=={{header|EchoLisp}}==
Use '''memoization''' with the recursive version.
<lang scheme>
(define (fib n)
(if (< n 2) n
(+ (fib (- n 2)) (fib (1- n)))))
(remember 'fib #(0 1))
(for ((i 12)) (write (fib i)))
0 1 1 2 3 5 8 13 21 34 55 89
</lang>
=={{header|ECL}}==
|