Skip to content

Instantly share code, notes, and snippets.

@jingning42
Forked from cuihaoleo/fib
Last active August 29, 2015 14:06
Show Gist options
  • Save jingning42/e1bb7abfdea9a726d429 to your computer and use it in GitHub Desktop.
Save jingning42/e1bb7abfdea9a726d429 to your computer and use it in GitHub Desktop.
def fib (m):
a, b, c = 0, 1, 1
yield 1
while a+b <= m:
c = a + b
yield c
a, b= b, c
s = 0
for i in fib(4000000):
if i%2 == 0:
s += i
print s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment