mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
Updated sol2.py to make it work as expected
This commit is contained in:
parent
8727246ed7
commit
16cd42c26c
@ -1,13 +1,12 @@
|
||||
def fib(n):
|
||||
ls = []
|
||||
a,b = 0,1
|
||||
n += 1
|
||||
for i in range(n):
|
||||
if (b % 2 == 0):
|
||||
ls.append(b)
|
||||
else:
|
||||
pass
|
||||
a,b = b, a+b
|
||||
print (sum(ls))
|
||||
return None
|
||||
fib(10)
|
||||
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')
|
||||
|
Loading…
Reference in New Issue
Block a user