Calculated the factorial of given Number ~ IN JAVA
PROGRAME THAT CALULATED THE FACTORIAL NUMBER OF GIVEN NUMBER IN JAVA
import java.util.Scanner;
public class FactorialNumber {
public static void main(String[] args) {
System.out.println(factorialNumber(input("WELCOME IN CALCULATED FACTORIAL PROGRAM !! \n\n Enter the number: ")));
}
// These function use for taking input from user
private static int input(String command) {
Scanner input = new Scanner(System.in);
System.out.print(command);
return input.nextInt();
}
// This function calculated the factorial number
private static long factorialNumber(int number){
long i = 1, result = 1;
while (i <= number){
result *= i;
i++;
}
return result;
}
}
Comments
Post a Comment