* @param args
* @param numOfDays 总天数
* @return 第一天总共摘的桃子数
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
GetPeach getPeach = new GetPeach();
int num = getPeach.getNumOfPeachFirstDay(10);
System.out.println(" 猴子第一天一共摘下了"+num+"个桃子");
}
public int getNumOfPeachFirstDay(int numOfDays) {
if (numOfDays < 1) {
throw new RuntimeException("NumOfDays must more than zero!");
}
if (numOfDays == 1) {
return 1;
}
//第numOfDays-1的桃子数
int num =getNumOfPeachFirstDay(numOfDays - 1);
return ( num+ 1) * 2;
}