Skip to content

Instantly share code, notes, and snippets.

@opensourceame
Last active August 31, 2017 22:36
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 opensourceame/24f43ccc42a47d246931fbcd84afa668 to your computer and use it in GitHub Desktop.
Save opensourceame/24f43ccc42a47d246931fbcd84afa668 to your computer and use it in GitHub Desktop.
fibonacci series in Ruby
# output the fibonacci series to n in the series
#
def fibonacci(n, last = 1, previous = 0)
puts previous
current = last + previous
return if n == 0
fibonacci(n - 1, current, last)
end
fibonacci(100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment