Python – 求斐波那契数列前N项之和

  • Post author:
  • Post category:python


n = int(input("Input N: "))
a = 0
b = 1
sum = 0
for i in range(n):
sum += a
a, b = b, a + b
print("The sum of", n, "FIB is", sum,"!")



版权声明:本文为hydhyd2012原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。