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