Skip to content

Instantly share code, notes, and snippets.

@devinrhode2
Last active August 29, 2015 14:07
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 devinrhode2/3dbfcc1aaabbb06ca6b9 to your computer and use it in GitHub Desktop.
Save devinrhode2/3dbfcc1aaabbb06ca6b9 to your computer and use it in GitHub Desktop.
# Fibonacci sequence
fibs = [1,2]
while (leadingFib = fibs[-1] + fibs[-2]) < 4000000 do
fibs.push(leadingFib)
end
puts fibs.select{ |i| i%2==0 }.inject(:+)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment