public class factorial {
public static void main(String[] args) {
int num = 6;
int fact = 1;
int temp=num;
while (num > 0) {
fact = fact * num;
num--;
}
System.out.println("The factorial of " + temp + " is : " + fact);
}
}
Output : The factorial of 6 is : 720
Post a Comment