Program Code :
import java.util.Scanner;public class Factorial{public static void main(String[] args){Scanner scn =new Scanner(System.in);int a,n,f=1;System.out.println("Enter a number to find out factorial =");n=scn.nextInt();for(a=1;a<=n;a++)f=f*a;System.out.println(n+" ! = "+f);}}
Output :
Enter a number to find out factorial =
10
10 ! = 3628800