package com.tutorial4u;
import java.util.Scanner;
public class FactorialNumber {
public static void main(String[] args) {
System.out.print("Enter any number to find factorial : ");
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
int factorial = 1;
for(int i = 1; i<=num;i++){
factorial = factorial*i;
}
System.out.println("Factorial of Enter number "+num+" is : "+factorial);
}
}
Enter
any number to find factorial : 5
Factorial
of Enter number 5 is : 120
No comments:
Post a Comment