Java Program to find factorial of a number

Java Program to find factorial of a number

Write a Java program to find factorial of a number is one of the common Java interview questions mostly asked for freshers. Factorial of a number N is represented as,

N! = N * (N-1) * (N-2) * … * 1.

In this post we will see Java program to find factorial of a given number using loop and recursion.

Factorial program using loop

Factorial program using recursion

You can also use third party API like Apache Commons Math’s CombinatoricsUtils.factorial(int n) to find the factorial of a number.

Also read my posts on Frequently asked Java interview questions with answers.

Hope you find the post useful. If you have any comments, post it in the comments section.

The following two tabs change content below.
Working as a Java developer since 2010. Passionate about programming in Java. I am a part time blogger.
3 comments

Add Comment

Required fields are marked *. Your email address will not be published.