Monkey eating peaches problem

100 Classic C Examples

One day, a little monkey picked many peaches. On the first day, it ate half of them, and then couldn't resist eating one more. On the second day, it ate half of the remaining peaches, plus one more. It kept eating this way every day after that. By the tenth day, the little monkey found there was only one peach left. The question is: how many peaches did the little monkey pick in total on the first day?

Example

#include<stdio.h> int main() { int i = 1; int j = 1; for (j = 10; j > 1;j --) { i++; i = 2 * i; } printf("On the first day, %d peaches were picked.", i); }

The output result of the above example is:

第一天摘了 1534 个桃子。

100 Classic C Examples

other extensions