
Python
- 200 ответов
- 0 вопросов
79
Вклад в тег
def fib(n):
i = 0
x1 = 0
x2 = 1
result = []
while i < n:
x3 = x1 + x2
result.append(x1)
x1 = x2
x2 = x3
i += 1
return result
def summa(n):
start = fib(n)
end = []
i = 0
while i < n:
if start[i] % 2 == 0:
end.append(start[i])
i += 1
return sum(end), sum(end) < 4000000
if __name__ == "__main__":
n = int(input("Введите количество елементов: "))
if summa(n)[1]:
print(summa(n)[0])
else:
print("Сумма четных елементов больше 4000000")