首先先要知道,math.log()方法用于返回参数的自然数底数的对数值。
所以 这个题目可以写
package Exersice;
public class Exercise_1_1_20 {
public static double ln(int N) {
if(N==0)
return 0;
else
return (Math.log(N)+ln(N-1))//递归
}
public static void main(String[] args) {
int N=10;
System.out.println(ln(N));
}
}