Monkey Peach Problem
A little monkey picked a lot of peaches one day. On the first day, he ate half of them and couldn't resist eating one more; on the second day, he ate half again and then one more; this pattern continued every day. By the 10th day, the monkey found there was only one peach left. How many peaches did the monkey pick on the first day?
Example
#include <iostream>
using 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