package algorithmsample30;
import java.util.Scanner;
/**
*
* @author Nurhak
*/
public class AlgorithmSample30 {
public static void main(String[] args) {
int number = 0;
int factorial = 1;
String data = "";
try {
Scanner scan = new Scanner(System.in);
System.out.println("Enter the number.");
data = scan.nextLine();
number = Integer.parseInt(data);
for (int i = number; i >= 1; i += -1) {
factorial = factorial * i;
}
System.out.println(number + " ! = " + factorial);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Comments
Post a Comment