Wednesday, 4 December 2013

Unknown

Factorial of a number


/*
 This program shows how to calculate
 Factorial of a number.
 */

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--) {
            4

        }
        {
            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
*/

Unknown

About Blog No Baap -

Since 2016 BlogNoBaap has been bringing you the very best in all types of web resources. Posted daily, and delivered straight to your inbox each morning.

Subscribe to this Blog via Email :