import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Factorial
{
public static void main(String[] args)
{
String input = JOptionPane.showInputDialog("Input Factorial");
int inputan = Integer.parseInt(input);
long faktorial=1;
for(int i=1;i<=inputan;i++){
faktorial=1;
for(int faktor=2;faktor <= i;faktor++)
faktorial *= faktor;
if(inputan==i){
JOptionPane.showMessageDialog(null,i +" !"+" = " +faktorial);
}
}
}
}
Using "Factorial" for file name
Capture
Input:
Output: