Java program to find factorial of user input


Program
import java.util.*; public class Factorial { public static void main(String[] args) { Scanner s=new Scanner(System.in); int n = s.nextInt(); long fact = 1; for(int i = 1; i <= n; ++i) { fact =fact * i; } System.out.println("Factorial of "+n+" is "+fact); } }
Input
Output