tell how to find factorial of a number using recursive approach in java
Answers
Answered by
0
Answer:
n! = n×(n-1) !:
Example:-5!= 5×(5-1)! =5×4!
=5×24= 120 .
Explanation:
Hope it helps you...☺️☺️
Answered by
0
Answer:
import java.util.*;
class Main
{
static long fact(int n)
{
if(n == 1)
{
return 1;
}
return n * fact(n-1);
}
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
System.out.println(fact(n));
}
}
Explanation:
Similar questions
India Languages,
2 months ago
English,
2 months ago
English,
2 months ago
Math,
4 months ago
Computer Science,
4 months ago
English,
10 months ago