package com.JavaInterview.Programs;
import java.util.*;
/**
* Find Out Factorial of a number
*
*
*/
public class Factorial {
public void findFactorial(int n) {
int fact = 1;
if (n < 0)
{
System.out.println("The Number should be non-negative");
} else {
for (int i =
1; i <= n; i++) {
fact = fact
* i;
}
}
System.out.println("factorial Of Number " + n + "
is : " + fact);
}
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Please enter the number :");
int num =
input.nextInt();
Factorial f = new Factorial();
f.findFactorial(num);
}
}
Output :
Please enter the number :
6
factorial Of Number 6 is : 720