题目:一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在第10次落地时,共经过多少米?第10次反弹多高?
//返回高度
public static double test2(int n){
if( n == 1){
return 50;
}else {
return test2(n-1)/2;
}
}
//返回经历的长度
public static double test3(int n){
if( n == 1){
return 100;
}else {
return test3(n-1)+test2(n-1)*2;
}
}