project_euler/src/problem2.py

21 lines
318 B
Python
Raw Normal View History

2024-02-06 13:34:24 +00:00
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)