Skip to content

Instantly share code, notes, and snippets.

@FGtatsuro
Created January 15, 2012 03:21
Show Gist options
  • Save FGtatsuro/1614128 to your computer and use it in GitHub Desktop.
Save FGtatsuro/1614128 to your computer and use it in GitHub Desktop.
program 2 in Euler
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def fibo():
a, b = 1, 2
while True:
yield a
a, b = b, a + b
ans = []
limit = 4000 * (10 ** 3)
f = fibo()
while True:
even = next(f)
print even
if even > limit:
break;
if even % 2 == 0:
ans.append(even)
print ans
print reduce(lambda x, y: x + y, ans)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment