题目:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,
假如兔子都不死,问每个月的兔子总数为多少?
'''
有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,
假如兔子都不死,问每个月的兔子总数为多少?
'''
month = int(input('繁殖几个月:'))
month_1 = 1 # 一个月大的兔子
month_2 = 0 # 二个月大的兔子
month_3 = 0 # 三个月大的兔子
adult = 0 # 成年的兔子
sum = 0 # 兔子总数
for i in range(month):
month_1,month_2,month_3,adult = adult+month_3,month_1,month_2,month_3+adult
print('第%d个月共有' %(i+1), month_1+month_2+month_3+adult,'对兔子')
print('一个月大的兔子:',month_1)
print('二个月大的兔子:',month_2)
print('三个月大的兔子:',month_3)
print('adult:',adult)
结果: