import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Factorial
{
public static void main(String[] args) throws NumberFormatException, IOException
{
long num;
System.out.println("Enter a number greater then or equal to 0 and less then 40 for which the factorial is desired:-");
InputStreamReader ir = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(ir);
num = Integer.parseInt(br.readLine());
if(num>=0 && num < 40)
{
if(num == 0)
{
num =1;
}
System.out.println(factorial(num));
}
else
{
System.out.println("Number out of range");
}
}
private static long factorial(long num)
{
if(num > 1)
{
num = num * factorial(num-1);
}
else
{
return num;
}
return num;
}
}