import java.io.IOException;
public class GetPeach {
/**
*
* @param args
*/
public static void main(String[] args) throws IOException{
System.out.println("the total number of the peach is:"+getNumPeach(10));
}
/**
* get the total number of the peach
* @param params
*/
private static int getNumPeach(int params) {
if(params < 1) {
throw new RuntimeException("params must more than zero!");
} else if (params == 1) {
return 1;
} else {
return (getNumPeach(params - 1) +1)*2;
}
}
}
|