Write a program to find the factorial of a number
FACTORIAL OF A NUMBER:
Eg: 5= 1 * 2 * 3 * 4 * 5 = 120
Eg: 7= 1 * 2 * 3 * 4 * 5 * 6 * 7 = 5040
import java.util. * ;
public class factorial {
public static void main(String[] args) {
int fact=1;
Scanner sc = new Scanner(System.in);
System.out.println("ENTER A NUMBER : ");
int n =sc.nextInt();
for(int i=1;i<=n;i++)
fact=fact*i;
System.out.println(fact);
}
}
FOR CODE : CLICK >> https://onecompiler.com/java/3ygsfjgv9 TO FIND OUTPUT
SUPPORT US >> https://onethoughttechnology.blogspot.com (OFFICIAL WEBSITE)