Skip to content

Instantly share code, notes, and snippets.

@pirj
Forked from egoholic/fibquence.rb
Created September 5, 2012 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pirj/3644179 to your computer and use it in GitHub Desktop.
Save pirj/3644179 to your computer and use it in GitHub Desktop.
Oneline fibonacci sequence generator
def fib n;n==0?[0]:n==1?[0,1]:(2..n-1).inject([0,1]){|a|a<<(a[-1]+a[-2])};end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment