Cpp Examples Monkey Eating Peach
# Monkey Eating Peach Problem
[ C++ Examples](#)
A little monkey picked many peaches one day. On the first day, it ate half of them, and then couldn't help but ate one more. On the second day, it ate half of the remaining peaches again, plus one more. This pattern continued every day. On the 10th day, the little monkey found there was only one peach left. How many peaches did the little monkey pick on the first day?
## Example
#includeusing namespace std; int main(){int x, y, n; for(x=1, n=0; n<9; y=(x+1)*2, x=y, n++); cout<<"The total number of peaches picked on the first day is "<<x<<endl; return 0; }
The output of the above example is:
The total number of peaches picked on the first day is 1534
[ C++ Examples](#)
YouTip