Monkey peach issue

Source: Internet
Author: User

One or five monkeys split peaches. In the middle of the night, the first monkey got up first, and it divided the peach into five equal heaps, one more. So it eats one and takes a pile of peaches. The second monkey gets up and looks at it, and there are only four peaches. So we combined the four heaps and divided them into five equal heaps, with one more. As a result, it also eats one and takes away a bunch of monkeys. Q: How many peaches are there at least?
1st monkeys: x = x-(x-1)/5-1 = 4/5 (x-1) If there is 1 monkey, the number of peaches is: 5 ^ 1-4
2nd monkeys: x = x-(x-1)/5-1 = 4/5 (x-1) if there are 2 monkeys, the number of peaches is: 5 ^ 2-4
3rd monkeys: x = x-(x-1)/5-1 = 4/5 (x-1) if there are 3 monkeys, the number of peaches is: 5 ^ 3-4
4th monkeys: x = x-(x-1)/5-1 = 4/5 (x-1) if there are 4 monkeys, the number of peaches is: 5 ^ 4-4
5th monkeys: x = x-(x-1)/5-1 = 4/5 (x-1) if there are 5 monkeys, the number of peaches is: 5 ^ 5-4
So, peach count is 5 ^ 5-4 = 3121

2. Monkey peach eating problem: the monkey picked a few peaches on the first day, and immediately ate half of them. It was not enough. Then, the monkey ate another one and eat half of the remaining peaches on the morning of the next day, I ate another one. In the future, I eat the remaining half of the previous day every morning. When you want to eat again in the morning of the seventh day, there is only one peach left. Calculate the total number of extracted items on the first day.

Int main (void) {int sum = 1, I; for (I = 0; I <9; I ++) sum = (sum + 1) * 2; printf ("monkeys picked % d peaches. \ N ", sum );}

// Monkeys picked 1534 peaches.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.