From 7d5737c68ab3faebc3ab7d41d157a77cd0f4a0c9 Mon Sep 17 00:00:00 2001 From: t3xhno Date: Tue, 6 Feb 2024 14:34:24 +0100 Subject: [PATCH] Problem2 --- lib/__pycache__/num_fns.cpython-310.pyc | Bin 0 -> 271 bytes lib/{num_functions.py => num_fns.py} | 0 src/problem1.py | 2 +- src/problem2.py | 20 ++++++++++++++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 lib/__pycache__/num_fns.cpython-310.pyc rename lib/{num_functions.py => num_fns.py} (100%) create mode 100644 src/problem2.py diff --git a/lib/__pycache__/num_fns.cpython-310.pyc b/lib/__pycache__/num_fns.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e058596d507ad51b7cc30d314f8186907d93edca GIT binary patch literal 271 zcmd1j<>g`kg8xQ`QcZ#MV-N=!FabFZKwQiNBvKes7+V;k7*d#m88n%bL2@tvVuP?V z5QEj$Fw`)L0o7-N)H3u2QWrs|iZR_F&5 z<);@V=H_PRr32ZC$t9V|srm&)`B|ySCGn}HIjKeZIhjfNKx5+5@{08eDsQo87Q1AY oIaM-(EC-p%!&t-yr2I4?G{PPTixnt$i^C>2KLu!-9YPla010I_hX4Qo literal 0 HcmV?d00001 diff --git a/lib/num_functions.py b/lib/num_fns.py similarity index 100% rename from lib/num_functions.py rename to lib/num_fns.py diff --git a/src/problem1.py b/src/problem1.py index feeea44..0ba8107 100755 --- a/src/problem1.py +++ b/src/problem1.py @@ -1,6 +1,6 @@ import sys sys.path.append("lib") -from num_functions import isDivBy +from num_fns import isDivBy sum = 0 diff --git a/src/problem2.py b/src/problem2.py new file mode 100644 index 0000000..97c41a9 --- /dev/null +++ b/src/problem2.py @@ -0,0 +1,20 @@ +import sys +sys.path.append("lib") +from num_fns import isDivBy + +def fib(i): + if i == 1: + return 1 + elif i == 2: + return 2 + return fib(i - 1) + fib(i - 2) + +sum = 0 + +for i in range(1, 1000000): + curr = fib(i) + if curr > 4000000: + break + if isDivBy(curr, 2): sum += curr + +print(sum)