The monkey picked some peaches on the first day , Half eaten immediately , Not yet , Another one . The next morning, he ate half of the remaining peaches and another one , After that, I ate half and one of the rest of the day before every morning . To the first 10 When you want to eat again in the morning , There's only one peach left . Please pick how many peaches on the first day ?
Reverse reasoning
Set the first 9 There is x Peach :
x - x / 2 - 1=1
be x=4
The code is
x = (x + 1) * 2
x = 1
for i in range(9):
x = (x + 1) * 2
print(" The first ", 9 - i,
" There are still peaches left before eating ", x, " individual ")
The first 9 There are still peaches left before eating 4 individual
The first 8 There are still peaches left before eating 10 individual
The first 7 There are still peaches left before eating 22 individual
The first 6 There are still peaches left before eating 46 individual
The first 5 There are still peaches left before eating 94 individual
The first 4 There are still peaches left before eating 190 individual
The first 3 There are still peaches left before eating 382 individual
The first 2 There are still peaches left before eating 766 individual
The first 1 There are still peaches left before eating 1534 individual
If you have a better solution or have different opinions , You can speak freely below , Jointly improve progress !
I'm also Xiaobai , Zero base learning python, Dare to ask questions , Let's discuss , Learn together and make progress !