Skip to content

Instantly share code, notes, and snippets.

@pirj
Forked from NILID/fibonacci.rb
Created September 5, 2012 21:25
Show Gist options
  • Save pirj/3645081 to your computer and use it in GitHub Desktop.
Save pirj/3645081 to your computer and use it in GitHub Desktop.
fibonacci
def fib(n)a,b,s=0,1,[];n.times{s<<a;c=b;b=a+b;a=c};s end
p fib(33)
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, ...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment