from lib_fibonacci import fibonacci_generator_smaller def euler_002(): fs = [f for f in fibonacci_generator_smaller(4000000) if f % 2 == 0] return sum(fs) assert(euler_002() == 4613732) print("e002.py: {}".format(euler_002())) def euler_002_simple(): """ Sometimes it is nice to keep it simple. Instead of using three library functions just implement one straightforward function. """ r, a, b = 0, 0, 1 while b < 4000000: if b % 2 == 0: r += b a, b = b, a + b return r assert(euler_002() == euler_002_simple())