Java Programming Sample – To calculate the factorial of a number

Java Programming Sample – To calculate the factorial of a number

java

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 http://www.helpwithassignment.com/programing-assignment-help and http://www.helpwiththesis.com


FLAT 25% OFF ON ALL HOMEWORK HELPSUBSCRIBE NOW
Not able to make up your mind?

Not able to make up your mind?

If you are here for the first time, you can request for a discount coupon, which can knock off upto 20% of the quoted price on any service.

 

Go ahead and send in your request!

You have Successfully Subscribed!