Topic: Monkey Eat Peach problem: The first day the monkey picked a number of peaches, immediately ate half, still not addicted, and eat a
The next morning he ate half the remaining peaches and ate one more.
Every morning after the last day of the rest of the half zero. On the 10th day of the morning when I wanted to eat again, I saw only one peach left.
Ask for the first day of the total number of pick.
Package wzs.arithmetics;
Question: Monkey eat peach problem: The monkey took off a number of peaches on the first day, ate half of it immediately, not addicted to it, ate one more
///The next morning ate half of the remaining peaches, ate one more
//every morning and ate half the rest of the day before. On the 10th day of the morning when I wanted to eat again, I saw only one peach left.
//Ask for a total number of the first day. Public
class TEST_WZS16
{public
static void Main (string[] args)
{
System.out.println (total (1));
System.out.println (Total (2));
System.out.println (Total (3));
System.out.println (Total (4));
System.out.println (Total (5));
System.out.println (Total (6));
System.out.println (Total (7));
System.out.println (Total (8));
System.out.println (Total (9));
SYSTEM.OUT.PRINTLN (total);
}
/**
* Number of peaches per day *
@param days
* @return The number of Peaches
/
static int total (int days)
{
If day = =)
{return
1;
}
else
{return
(Total (day + 1) + 1) * 2;
}
}}
Output results:
1534
766
382
190
4
1