Get Instant Help From 5000+ Experts For
Get Instant Help From 5000+ Experts For

Java Programming – Finding Factorial

By HWA | Publish On: February 1, 2011 | Posted In:

Java Factorial Example
This Java Factorial Example shows how to calculate factorial of a given number using Java.

public class NumberFactorial {
public static void main(String[] args) {

int number = 5;
* Factorial of any number is !n.
* For example, factorial of 4 is 4*3*2*1.

int factorial = number;

for(int i =(number – 1); i > 1; i–)

factorial = factorial * i;


System.out.println(“Factorial of a number is ” + factorial);

Here in the code we can see that in the first few lines the definition for a factorial is defined. Now, this definition is being applied in the following lines as “int factorial = number” or factorial of an integer equals to the number – 1; the number must be greater than 1 and the integer i is decremented by 1 until 1 is arrived at. The next process is the multiplication of the numbers obtained. This is seen in factorial = factorial*i. This will give the exact value of the factorial.

At we provide the best Assignment help, Homework help and Online Tutoring in Java and other Programming languages. Our tutors are experts in Java and other Programming Languages like C, C++, C#,,, QBasic, Perl, Fortran, etc. The list is not exhaustive.

For more details you can visit our website at and
You can follow us on our blogs at and
This is in continuation with our previous articles on Java and Java Assignment help

Book Your Assignment

Drop files here or click to upload.
Or click here to upload

Recent Posts

How To Prepare An Excellent Thesis Defense?

Read More

How to Restate A Thesis? – A Detailed Guide

Read More

Explanatory Thesis: Examples and Guide for Clear Writing

Read More

How To Write 3 Types Of Thesis Statements?

Read More

How to Effectively Prepare for Your Thesis Defense?

Read More

Get assignment help from subject matter experts!

4.7/5 rating | 10,000+ happy students | Great tutors 24/7