2 ms·
There are some other example implementations here: http://www.jsoftware.com/jwiki/Essays/Fibonacci%20Sequence http://www.jsoftware.com/jwiki/Essays/Fibonacci%2
by klibertp 12y ago
There are some other example implementations here:
http://www.jsoftware.com/jwiki/Essays/Fibonacci%20Sequence http://www.jsoftware.com/jwiki/Essays/Fibonacci%20Sequence
This:
f0b=: (-&2 +&$: -&1) ^: (1&<) M.
is probably the most elegant solution. It's recursive ($: stands for "self-reference"), memoized, and it works:
f0b&.> i.20
│0│1│1│2│3│5│8│13│21│34│55│89│144│233│377│610│987│1597│2584│4181│