python 斐波那契数列

#n1 = 0
#n2 = 1
#def F():
'''
def fac(n):
if n == 0:
return 1
else:
return n*fac(n - 1)
result = fac(5)
print(result)
'''
def fac(n):
if n == 0:
return 0
print(n)
elif n == 1:
return 1
print(n)
else:
return fac(n-1) + fac(n-2)

for n in range(0,10):
var = fac(n)
print('%d '%(var),end = '')
fac(9)

posted @ 2017-11-19 19:53  Bob__Zhang  阅读(221)  评论(0编辑  收藏  举报