import java.util.*;
import java.lang.*;
import java.io.*;
// The main method must be in a class named "Main".
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner (System.in);
System.out.println("Factorial");
System.out.println("enter a number");
int n = sc.nextInt();
// int n = 4;
int factor=1;
int factor2=1;
while (n>=1)
{
System.out.print(n+"×");
factor = (factor * n);
--n;
}
System.out.println("= "+factor);
// USING FOR LOOP
for (n=8; n>=1; n--)
{
System.out.print(n+"×");
factor2 = (factor2 * n);
// System.out.print(n);
}
System.out.println("= "+factor2);
}
}
To embed this program on your website, copy the following code and paste it into your website's HTML: