def fibo(n):
if n == 0 or n == 1:
return n
else:
return fibo(n - 1) + fibo(n - 2)
def main():
total = 0
a = 0
while a < 4000000:
if a % 2 == 0:
total += a
fibo(total)
print(total)
我的代码没有运行任何东西。我正在玩Python(所以没什么大不了但只需要帮助)
答案 0 :(得分:0)
def fibo(n):
if n == 0 or n == 1:
return n
else:
return fibo(n - 1) + fibo(n - 2)
if __name__ == '__main__':
total = 0
a = 0
while a < 4000000:
if a % 2 == 0:
total += a
fibo(total)
print(total)
尝试使用此功能。 或者只是
def fibo(n):
if n == 0 or n == 1:
return n
else:
return fibo(n - 1) + fibo(n - 2)
total = 0
a = 0
while a < 4000000:
if a % 2 == 0:
total += a
fibo(total)
print(total)