Skip to content

Instantly share code, notes, and snippets.

@phyous
Created February 7, 2013 05:19
Show Gist options
  • Save phyous/4728756 to your computer and use it in GitHub Desktop.
Save phyous/4728756 to your computer and use it in GitHub Desktop.
Gist test
# Array Method for computing fibbonacci number
def fib(n)
return n if n < 2
vals = [0, 1]
(n-1).times do
vals.push(vals[-1] + vals[-2])
end
return vals.last
end
# Test it out
10.times do |i|
puts fib(i)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment