Created
November 3, 2015 18:49
-
-
Save luketlancaster/a82a1e41833e9503f161 to your computer and use it in GitHub Desktop.
Fibonacci method
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
index = ARGV[0].to_i | |
def fibb(times) | |
start = [0] | |
times.times do |x| | |
if x.zero? | |
start << 1 | |
else | |
start << start[x -1] + start[x] | |
end | |
end | |
print start[times -1] | |
end | |
fibb(index) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
James Logan solution, in JS