Skip to content

Instantly share code, notes, and snippets.

@flakyfilibuster
Created December 14, 2012 23:11
Show Gist options
  • Save flakyfilibuster/4289481 to your computer and use it in GitHub Desktop.
Save flakyfilibuster/4289481 to your computer and use it in GitHub Desktop.
just some fibonacci functions
#recursive
def fibonacci(n)
n <= 1 ? n : fibonacci(n-1)+fibonacci(n-2)
end
# iterative
def fibonacci(n)
c,s = 0,1
n.times { c, s = s, c+s }
c
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment