from itertools import ifilterfalse
"terminating fibonacci sequence"
assert 0 < n1 <= n2 < fmax
l = [n2,n1]
if l < fmax/2:
if __name__ == "__main__":
print sum(ifilterfalse(lambda x: x % 2,fib()))
Friday, December 3, 2010
Python shines on this one. Find the sum of all the even-valued terms in the Fibonacci sequence which do not exceed four million.