6.8--2:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,

xiaoxiao2021-02-28  31

# 古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子, # 小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死, # 问每个月的兔子总数为多少? print('----------first------------') while True: month = input('What month do you want to enter:') if month.isdigit(): month = int(month) a = 0 b = 1 count = 0 while count < month-1: a,b = b,a+b count += 1 print(b) else: print('Invalid input!') print('----------second---------------') month = input('What month do you want to enter:') if month.isdigit(): month = int(month) a = 0 b = 1 for i in range(month-1): # print(b) a,b = b,a+b print(b) else: print('Invalid input!')

 

转载请注明原文地址: https://www.6miu.com/read-2612624.html

最新回复(0)