Problem2
This commit is contained in:
parent
993c2ea7bf
commit
7d5737c68a
BIN
lib/__pycache__/num_fns.cpython-310.pyc
Normal file
BIN
lib/__pycache__/num_fns.cpython-310.pyc
Normal file
Binary file not shown.
@ -1,6 +1,6 @@
|
|||||||
import sys
|
import sys
|
||||||
sys.path.append("lib")
|
sys.path.append("lib")
|
||||||
from num_functions import isDivBy
|
from num_fns import isDivBy
|
||||||
|
|
||||||
sum = 0
|
sum = 0
|
||||||
|
|
||||||
|
20
src/problem2.py
Normal file
20
src/problem2.py
Normal file
@ -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)
|
Loading…
Reference in New Issue
Block a user