Java Program to find Factorial of a Number

As you all know the working of a Factorial function, so you may wonder how to implement this function in JAVA Programming to find out the correct result of factorial of any given number. So, this tutorial is for you if you are searching the source code with output for a JAVA program to find or calculate the factorial.

JAVA Source Code to find out Factorial of any Number :

import java.util.Scanner; // using Scanner class to get input from user
public class Fact {
public static void main(String mridul[])
{System.out.println("Java Program to find factorial of a number.");
System.out.println("Enter the number");
Scanner num = new Scanner(;
int number = num.nextInt();
double factn = 1;
 factn = factn * number;
System.out.println("The factorial of given number"  + "is" + factn);    }

Output of Java Program to find Factorial 

Java Program to find factorial of a number.
Enter the number
 The factorial of given number is 120.0

CMD Screenshot of Java Program for Factorial  

What is the meaning of Factorial in this Program

The above factorial method which we have implemented in our Java program source code is multiplying a series of descending natural numbers untill it encounters the 1, after that it returns the multiplied value.


Post a Comment