Skip to content

Instantly share code, notes, and snippets.

@havenwood
Forked from anonymous/gist:5605311
Last active December 17, 2015 11:49
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 havenwood/5605341 to your computer and use it in GitHub Desktop.
Save havenwood/5605341 to your computer and use it in GitHub Desktop.
def fib n
a, b = 1, 2
sum = 0
while a < n
sum += a if a.even?
a, b = b, a + b
end
sum
end
fib 4_000_000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment