# 斐波那契数列:https://www.python.org/
def fib(n):
a, b = 0, 1
s=0
while a < n:
print(a , end=' ')
a, b = b, a+b
print()
fib(8)
i,num,n1,n2=1,1,0,0
while i<=8:
if i==1:
print("第一个月:有%d对" %num)
n1=num
elif i==2:
print("第二个月:有%d对" %num)
n2=num
else:
num=n1+n2
# print("第%i个月兔子有%d对" %(i,num))
print('第{}个月有{}对兔子.'.format(i,num))
n2=n1
n1=num
i+=1
# 递归做法
def jc (n):
if n <= 2:
return 1
return jc(n-1) + jc(n-2)
print('共有{}对兔子'.format(jc(8)))