factorial


See On Github

Data

Contributor

Generic placeholder thumbnail

by aesptux

in python

Source Code

### Factorial

http://en.wikipedia.org/wiki/Factorial

In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example,

The value of 0! is 1, according to the convention for an empty product.

![Factorial of 5](http://upload.wikimedia.org/math/9/3/9/939c013423574cad70f33eaa7dd68f0c.png)



Definition:

![Factorial Definition](http://upload.wikimedia.org/math/a/9/1/a91da51a80ac8291d8dbcc4cb77c0936.png)


def factorial_recursive(num):
    """returns the factorial of num using a recursive method."""
    return 1 if num == 0 else num * factorial_recursive(num -  1)
import factorial

print factorial.factorial_recursive(0)
print factorial.factorial_recursive(1)
print factorial.factorial_recursive(5)