Created
June 1, 2016 09:40
-
-
Save anonymous/12f18e0cc4e0b47cd39134ba26d6271d to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
MAX = 4000000 | |
def fib(max_): | |
n1, n2 = 1, 1 | |
while n2 <= max_: | |
yield n2 | |
n1, n2 = n2, n1+n2 | |
def is_even(n): | |
return not (n & 1) | |
def main(): | |
f = fib(MAX) | |
print(sum(filter(is_even, fib(MAX)))) | |
if __name__ == "__main__": main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment