打印斐波拉契数列前n项
#encoding=utf-8
def fibs(num):
result =[0,1]
for i in range(num-2):
result.append(result[-2]+result[-1])
return result
print fibs(10)
结果:
2023-01-27 12:55:36
#encoding=utf-8
def fibs(num):
result =[0,1]
for i in range(num-2):
result.append(result[-2]+result[-1])
return result
print fibs(10)
结果: