Java 题目:编写一个函数,输入n为偶数时,调用函数求1/2+1/4+...+1/n,当输入n为奇数时,调用函数1/1+1/3+...+1/n
public static double test13(int n){double f;
if(n == 1){
f = 1/(double)n;
}else if(n == 2){
f = 1/(double)n;
}else{
f = 1/(double)n+test13(n-2);
}
return f;
}
Java 题目:编写一个函数,输入n为偶数时,调用函数求1/2+1/4+...+1/n,当输入n为奇数时,调用函数1/1+1/3+...+1/n
public static double test13(int n){