Skip to content

Instantly share code, notes, and snippets.

@johana-star
Created May 26, 2011 05:43
Show Gist options
  • Save johana-star/992615 to your computer and use it in GitHub Desktop.
Save johana-star/992615 to your computer and use it in GitHub Desktop.
Euler Project Problem #002
# Solution to Project Euler's second problem
# http://projecteuler.net/index.php?section=problems&id=2
# Sum all even numbers in the Fibonnacci sequence below 4000000.
i1, i2, sum = 1, 1, 0
until i1 > 4000000
if i1.even? then sum = sum + i1 end
i1 = i1 + i2
if i2.even? then sum = sum + i2 end
i2 = i2 + i1
end
puts sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment