Skip to content

Instantly share code, notes, and snippets.

@carnotweat
Created December 10, 2011 11:26
Show Gist options
  • Save carnotweat/1454954 to your computer and use it in GitHub Desktop.
Save carnotweat/1454954 to your computer and use it in GitHub Desktop.
euler
fib1
=========
`def fib(a=0, b=1):
while True:
yield a
a, b = b, a + b
sum_ = 0
for f in fib():
if f > 4000000:
break
if f % 2 == 0:
sum_ += f
print sum_`
def fib(n):
if n == 0:
return 0
elif n == 1:
return 1
else:
return fib(n-1) + fib(n-2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment