Created
November 10, 2011 14:02
-
-
Save betawaffle/1354913 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FIB = [0, 1] | |
def fib(n, seed = nil) | |
seed = FIB.take(n).each { |x| puts x } unless seed | |
seed << (seed[-1] + seed[-2]).tap { |x| puts x; FIB << x } if seed.size == n | |
while s = seed.size and s < n | |
fib(s, seed) | |
end | |
seed[n] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment