import java.util.Scanner; class Factorial { void fact(int n) { int x,f=1; for(x=1;x<=n;x++) { f=f*x; } System.out.println(f); } } public class Main { public static void main(String args[]) { int n; Factorial ff=new Factorial(); Scanner s=new Scanner(System.in); System.out.println("Enter n value : "); n=s.nextInt(); ff.fact(n); } }
Enter n value : 5
120