import java.util.*; class Factorial { int n; Factorial(int m) { n=m; } int fact(int x,int f) { for(x=1;x<=n;x++) { f=f*x; } return(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); int p=ff.fact(1,1); System.out.println(p); } }
Enter n value : 5
120