Created
March 13, 2012 08:43
-
-
Save shieldsd/2027626 to your computer and use it in GitHub Desktop.
Project Euler #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import takewhile | |
def fib(): | |
a, b = 1, 1 | |
while 1: | |
yield a | |
a, b = b, a + b | |
print sum(n for n in takewhile(lambda f: f < 4000000, fib()) if n % 2 == 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment