Below is my code:
import
java.util.Scanner;
class
factorial
{
public
static void main(String s[])
{
int
a,b,c=1;
System.out.println("enter
no. ");
Scanner
scan=new Scanner(System.in);
a=scan.nextInt();
System.out.println("you
entered"+a);
for(b=a;b>0;b--)
{
c=c*b;
}
System.out.println("factorial
"+c);
}
}
Step 1: After writing this in notepad
save the file with the name followed by (.java) for eg. I saved it with factorial.java
Step 2 : Open command prompt
Step 3 : Write javac factorial.java - Press
Enter for compilation
Step 4
: Write java
factorial for execution
Now output:

Image 1.