Here you will get a program for factorial in java.
We can discover factorial of any number by duplicating it with every one of the numbers underneath it.
For instance, factorial of 4 is 432*1 = 24.
Program
package com;
import java.util.Scanner;
class Factorial
{
public static void main(String...s)
{
int n,fac=1,i;
Scanner sc = new Scanner(System.in);
System.out.println("Enter a number: ");
n = sc.nextInt();
for(i=1;i<=n;i++)
fac*=i;
System.out.println("\nFactorial = "+fac);
sc.close();
}
}
Output
Enter a number:
6
Factorial = 720