Skip to content

Instantly share code, notes, and snippets.

@pirj pirj/fibonacci.rb

forked from NILID/fibonacci.rb
Created Sep 5, 2012
Embed
What would you like to do?
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
You can’t perform that action at this time.