Factorial of a number :Unleashed
For factorial of a number recursive program click the given link.
Factorial of a number is the product of the numbers from 1 up to the number.
Write a program to accept a number and print its factorial. For example the factorial of 4 is 24(4 X 3 X 2 X 1)
For factorial of a number recursive program click the given link.
Factorial of a number (Recursive Function)
import java.io.*;
class factorial
{
public static void main()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a number of your choice");
int n=Integer.parseInt(br.readLine());
int fact=1;
for(int i=1;i<=n;i++)
{
fact*=i;
}
System.out.println("The factorial of the number is"+ fact);
}
}Output: Enter a number of your choice
4
The factorial of the number is 24
To learn how to take input using BufferedReader watch the video
https://youtu.be/bTOMwnwpXqs
Related Posts
Continue learning with these related articles

String Methods in Java for ICSE Class 10: 25 Output Questions with Answers
ICSE Class 10 Computer Applications practice on String class methods: length, charAt, indexOf, lastIndexOf, substring, replace, trim, compareTo, equals and more, with 25 board-style output questions and step-by-step answers.

Special Number Programs in Java for ICSE: Armstrong, Spy, Neon, Disarium, Pronic and More
Every special number asked in ICSE Computer Applications – prime, perfect, Armstrong, palindrome, automorphic, neon, spy, Niven, duck, buzz, Disarium, special and pronic numbers – with definitions, examples and one complete Java program that checks them all.

Math Library Methods in Java for ICSE Class 9 (with Outputs)
ICSE Class 9 Computer Applications notes on the Java Math class: sqrt, cbrt, pow, abs, max, min, ceil, floor, round, rint and random, with return types, tricky negative-number outputs and Java expressions for formulas.