Sunday, 8 January 2017

Java Program to Calculate Factorial of a Given Number

Problem:- Factorial Program in Java or Java program to find factorial or Java Program to Find Factorial of Number or Java Program to Find Factorial Value Without Using Recursion or Java Program to Find Factorial or Write java code to calculate factorial of any given number or Finding Factorial of a Number in Java or Factorial Program In Java Using While Loop or Factorial Program In Java Using for Loop or Java Program To Calculate Factorial using standard values with outputs or Write a Java Program To Calculate Factorial Of A Given Number.


What Is Factorial:- In mathematics, the factorial of a non-negative integer n, denoted by n! is the product of all positive integers less than or equal to n.


For example

5! = 5 * 4 * 3 * 2 * 1 = 120.

The value of 0! is 1, according to the convention for an empty product * The factorial operation is encountered in many areas of mathematics, notably in combinatorics, algebra, and mathematical analysis. Its most basic occurrence is the fact that there are n! ways to arrange n distinct objects into a sequence (i.e., permutations of the set of objects). This fact was known at least as early as the 12th century, to Indian scholars.
Source:- Wikipedia

See Also:- C Program To Calculate Factorial Of A Given Number

Java Program to Find Factorial of a Given Number


import java.util.Scanner;
import java.io.*;

/* Program By Ghanendra Yadav
   Visit http://www.programmingwithbasics.com
*/

public class factjava
{
    public static void main(String args[])
    {
        int fact=1,num,i; 
        Scanner sc = new Scanner(System.in);
 
        System.out.print("Enter The Number That You Want Factorial : \n\n");
        num = sc.nextInt();
 
  for(i=1;i<=num;i++)
  {
   fact=fact*i;
  }
    
  System.out.print("\nFactorial Is = "+fact); 
 }
} 

See Also:- C++ Program To Calculate Factorial Of A Given Number

Output:-


Java Program to Calculate Factorial of a Given Number

You May Also See


1.C++ Program For (FCFS) FIRST COME FIRST SERVE Scheduling Algorithm In Linux

2. C++ Program For PRIORITY Scheduling Algorithm In Linux

3. C++ Program To Print A Given Reverse STAR Pattern

4. C++ Program To Print Half Pyramid Using *

5. C++ Program To Print Reverse Half Pyramid Using *

Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date. If you have any Query or Question you can ask in the group, I will Try To Solve your Query and try to answers of your Questions withing 24 Hours, You can also Email me or comment below Please suggest to your Friends to join and like our page and don't forget to Subscribe. Enter your Email and click to subscribe.

Ghanendra Yadav

Ghanendra Yadav

Hello, I Am Ghanendra Yadav Owner of This Blog, I am professional Blogger and Programmer. I Love Programming, Logo Making, And Banner Designing. My Highest Qualification is MCA From NIT Warangal. You Can Find Me On Social Media Through Below Link And If You Have Any Query Related To Programming And Other Subject Comment Below or You Can Mail Me I Will Try To Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

No comments:

Post a Comment