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