University of Calgary

factorial!

Compute the Factorial

 source: Tino Duong, 2003

Description:

The factorial function is given by:



For example:

    3! = 3*2*1 = 6
    4! = 4*3*2*1 = 24

Factorials are useful because they give the number of ways in which n objects can be permuted. For example, , since the six possible permutations of are , , , , , .

Your job is to write a simple program what will compute N!.

Requirements:

    The output should be similar to this:

    Please enter the value (N) 
    6
    The iterative method gives the value of : 720
    The recursive method gives the value of : 720

Concepts:



Updated: August 29, 2005 12:17 AM