JAVA RECURSION Add all 3 recursive recursive methods from th
JAVA \"RECURSION\"
Add all 3 recursive recursive methods from this presentation to your previous Recursion lab Write a recursive method that computes the value of ln(N!) What is a good name for your method?Solution
// Test.java
import java.util.Scanner;
class Test
{
public static double ln_n_factorial(int n)
{
if(n==1)
return 0;
return ln_n_factorial(n-1) + Math.log(n);
}
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
System.out.print(\"Enter n: \");
int n = sc.nextInt();
System.out.println(\"ln(\"+n+\"!) = \" + ln_n_factorial(n));
sc.close();
}
}
/*
output:
Enter n: 4
ln(4!) = 3.1780538303479453
Enter n: 3
ln(3!) = 1.791759469228055
*/
