package test;
public class FactorialNumber {
public static void main(String[] args) {
//1
//1x2 2!
//1x2x3 3!
int givenNum = 5;
int calculatedNum = 1;
for (int i = 0; i < givenNum; i++) {
calculatedNum = calculatedNum * (givenNum - i);
}
System.out.println("The factorical number of the given number = " + calculatedNum);
}
}
Output:
The factorical number of the given number = 120
No comments:
Post a Comment