import java.util.*; class Factorial { int n; Factorial(int m) { n=m; } void fact() { 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; Scanner s=new Scanner(System.in); System.out.println("Enter n value : "); n=s.nextInt(); Factorial ff=new Factorial(n); ff.fact(); } }
Enter n value : 5
120