diff --git a/problem2.py b/problem2.py new file mode 100644 index 0000000..bf3837e --- /dev/null +++ b/problem2.py @@ -0,0 +1,9 @@ +def fib(limit=None): + a, b = 1, 2 + yield a + yield b + while (not limit or a + b < limit): + a, b = b, a + b + yield b + +print(sum(n for n in fib(4_000_000) if n % 2 == 0))