Recursive Algorithm in C Language -- monkey peach Extraction

Source: Internet
Author: User

Recursive Algorithm in C Language -- monkey peach Extraction
Q: The monkey picked up a few peaches on the first day and immediately ate half of them. The monkey was so addicted that he ate another peach. The next morning, I ate another half of the remaining peaches, and I ate another one. In the future, the remaining half of the previous day will be eaten every day, and one peach will be left when you want to eat it again on the morning of the seventh day. How many peaches can be picked on the first day.

# Include <stdio. h> int main () {int I; int B = 1; int c; for (I = 9; I> 0; I --) {c = 2 * (B + 1); B = c;} printf ("% d peaches in total \ n", B); return 0 ;}

 

Related Article

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.