### Factorial in java

In this core java programming tutorial we will write a program to Find factorial of number in java.

In this program we will find out factorial of number.

input: 4
output: 24

Q.How we caluclate factorial in java?
A.Let’s say our input is: 4
Than our factorial is 4x3x2x1 = 24.

Full Program/SourceCode/ Example in java >
 /** Copyright (c), AnkitMittal www.JavaMadeSoEasy.com */ public class FactorialExample {    public static void main(String...args){           int num=4;           System.out.println("Factorial of "+num+" is: "+findFactorail(num));        }       /*    * return factorial of num.    */    public static int findFactorail(int num){           int factorial=1;           while(num>0){                  factorial=factorial*num;                  num--;           }           return factorial;    } } /*OUTPUT Factorial of 4 is: 24 */

So, in this core java programming tutorial we wrote a program to Find factorial of number in java, we learned how to calculate factorial of number in java.

Having any doubt? or you you liked the tutorial! Please comment in below section.