- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex80.py
More file actions
Latest commit
30 lines (25 loc) · 871 Bytes
/
Copy pathex80.py
File metadata and controls
30 lines (25 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
'''
海滩上有一堆桃子,五只猴子来分。第一只猴子把这堆桃子
平均分为五份,多了一个,这只猴子把多的一个扔入海中,
拿走了一份。第二只猴子把剩下的桃子又平均分成五份,
又多了一个,它同样把多的一个扔入海中,拿走了一份,
第三、第四、第五只猴子都是这样做的,问海滩上原来最
少有多少个桃子?
'''
num=int(input("输入猴子的数目:"))
deffn(n):
ifn==num:
return4*x# 最后剩的桃子的数目
else:
returnfn(n+1) *5/4+1
x=1
while1:
count=0
foriinrange(1, num):
iffn(i) %4==0:
count=count+1
ifcount==num-1:
print("海滩上原来最少有%d个桃子"%int(fn(0)))
break
else:
x=x+1