Write a program to calculate the factorial of a number in java.
import java.util.Scanner;
public class star {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int fact=1;
int n=sc.nextInt();
for (int i=1;i<=n;i++)
fact=fact*i;
System.out.println(fact);
}
}
🔗Reference: stackoverflow.com
🔗Source: Java Interview Questions and Answers