Answer:
// Factorials.java
// library
import java.util.*;
// class definition
class Factorials
{
// main method of the class
public static void main (String[] args) throws java.lang.Exception
{
try{
// variable to store Factorial
int fact=1;
// find Factorial of all from 1 to 10
for(int i=1;i<=10;i++)
{
// calculate Factorial
fact=fact*i;
// print Factorial
System.out.println("Factorial of "+i+" is: "+fact);
}
}catch(Exception ex){
return;}
}
}
Step-by-step explanation:
Declare and initialize a variable "fact=1" to store the Factorial of a number. Run a for loop from 1 to 10.Fact will multiplied by value of i and that will be the Factorial of "i".Print the Factorial of "i".This will continue for i=1 to i=10.
Output:
Factorial of 1 is: 1
Factorial of 2 is: 2
Factorial of 3 is: 6
Factorial of 4 is: 24
Factorial of 5 is: 120
Factorial of 6 is: 720
Factorial of 7 is: 5040
Factorial of 8 is: 40320
Factorial of 9 is: 362880
Factorial of 10 is: 3628800