Skip to content

Instantly share code, notes, and snippets.

Created June 1, 2016 09:40
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 anonymous/12f18e0cc4e0b47cd39134ba26d6271d to your computer and use it in GitHub Desktop.
Save anonymous/12f18e0cc4e0b47cd39134ba26d6271d to your computer and use it in GitHub Desktop.
#!/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