一、python实现斐波那契数列
fibs=[0,1]
num = input('how many fibonacci numbers do you want?')
for i in range(num-2):
fibs.append(fibs[-2]+fibs[-1])
print fibs
2.内建的callable函数可以判断函数是否可调用
print callable(func)
二、采用函数调用形式,实现自定义数字的斐波那契数列
def fibs(num):
result = [0,1]
for i in range(num-2):
result.append(result[-2]+result[-1])
return result
print fibs(10)
print fibs(5)
三、