public class JavaExample { public static void main(String[] args) { Scanner sc= new Scanner(System.in); System.out.print("Enter Any Number : "); //We will find the factorial of this number int number = sc.nextInt(); long fact = 1; int i = 1; while(i<=number) { fact = fact * i; i++; } System.out.println("Factorial of "+number+" is: "+fact); } }