Skip to content

Instantly share code, notes, and snippets.

@pirj pirj/fibquence.rb forked from egoholic/fibquence.rb
Created Sep 5, 2012

Embed
What would you like to do?
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
You can’t perform that action at this time.