Java Common Algorithm questions (16)

Source: Internet
Author: User

 PackageCom.xiaowu.demo;//Monkey Eat Peach problem: The first day of monkeys to take off a number of peaches, immediately ate half, still not enjoyable, and eat one more;//The next morning he ate half of the remaining peaches and ate one more. //every morning after eating the rest of the day half of the zero one. By the 10th morning when I wanted to eat again, there was only one peach left. Ask how many peaches were picked on the first day.  Public classDemo16 { Public Static voidMain (string[] args) {intsum = Peach (1); System.out.println ("First day of the total pick up" + sum + "peach"); }     Public Static intPeachintDay ) {        if(Day = = 10) {            return1; } Else {            return(Peach (day + 1) + 1) * 2; }    }}

Java Common Algorithm questions (16)

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.