mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-27 02:12:31 +08:00
increment 1
This commit is contained in:
12
project_euler/Problem 02/sol2.py
Normal file
12
project_euler/Problem 02/sol2.py
Normal file
@ -0,0 +1,12 @@
|
||||
def fib(n):
|
||||
a, b, s = 0, 1, 0
|
||||
while b < n:
|
||||
if b % 2 == 0 and b < n: s += b
|
||||
a, b = b, a+b
|
||||
ls.append(s)
|
||||
|
||||
T = int(input().strip())
|
||||
ls = []
|
||||
for _ in range(T):
|
||||
fib(int(input().strip()))
|
||||
print(ls, sep = '\n')
|
Reference in New Issue
Block a user