猴子吃桃问题
源程序:
day = 10
while True:
m = day
flag = True
for i in range(9):
if m % 2 == 0:
m = m - m//2 - 1
else:
flag = False
break
if m == 1 and flag:
break
day = day + 1
print("第一天桃子的数量是:", day)
for i in range(9):
print(i+1, day, "->", day-day//2-1)
day = day - day//2 - 1
运行结果: