Example #1
0
File: euler.py Project: jdp/euler
def euler_25():
    """What is the first term in the Fibonacci sequence to contain 1000 digits?"""
    from itertools import takewhile
    from eutil import fib, ilen

    return ilen(takewhile(lambda x: len(str(x)) < 1000, fib()))
Example #2
0
File: euler.py Project: jdp/euler
def euler_2():
    """By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms."""
    from itertools import takewhile
    from eutil import fib

    return sum(filter(lambda x: x % 2 == 0, takewhile(lambda y: y < 4000000, fib())))