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

Java Programming Sample – To calculate the factorial of a number

By HWA | Publish On: September 2, 2011 | Posted In:

Java Programming Sample

The programming example is about how to calculate the factorial of a number

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);

}

}

/*

Output of the Factorial program would be

Factorial of a number is 120

*/

For more details you can visit our websites at https://www.helpwithassignment.com/programing-assignment-help and http://www.helpwiththesis.com

Book Your Assignment

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

Recent Posts

200+ Exclusive Legal Thesis Topics For 2024

Read More

How To Write Methodology In Thesis?

Read More

Boost Your Thesis Writing: 11 Proven Tips with Statement Examples!

Read More

The Ultimate Guide to Crafting a Killer Thesis Statement

Read More

6 Essential Steps To Kickstart Your Thesis Writing Process

Read More

Get assignment help from subject matter experts!

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