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; for(int i = 1; i <= number; i++) { fact = fact * i; } System.out.println("Factorial of "+number+" is: "+fact); } }