Skip to content

Instantly share code, notes, and snippets.

@gabrielmansour
Created June 6, 2013 23:54
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 gabrielmansour/5726021 to your computer and use it in GitHub Desktop.
Save gabrielmansour/5726021 to your computer and use it in GitHub Desktop.
$fib = Hash.new { |_,n| n < 2 ? n : $fib[n-1] + $fib[n-2] }
def fibsequence(n)
(0...n).map{ |i| $fib[i] }.join(',')
end
100.times do |i|
puts [i, fibsequence(i)].join(' - ')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment