Skip to content

Instantly share code, notes, and snippets.

@cuihaoleo
Created September 28, 2014 01:34
Show Gist options
  • Save cuihaoleo/be106a09277f796a2548 to your computer and use it in GitHub Desktop.
Save cuihaoleo/be106a09277f796a2548 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