From 5b51f105637d01e0fe902c9ccbac9d9e4028d217 Mon Sep 17 00:00:00 2001 From: Dece Date: Sun, 29 Dec 2019 02:57:17 +0100 Subject: [PATCH] Problem 2 --- problem2.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 problem2.py 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))