Recursion

Home  Writing  Games  Music  Dev  About 

Recursion

Factorial Example

Why is 0! = 1? Well, because it is defined so, firstly. Secondly, a factorial can be thought of as the number of permutations (unique orderings of elements) for a set with n elements And basically, because there is still one way to represent a set/sequence/permutation of 0!, that is an empty set. That is, can be represented in one way. So the answer is still one. This definition also works for the combinations formula (combination is a grouping of elements of a set without regard to order.) Reference.

Definition:

n! => 
    n! * (n-1)! for n > 1 
    1 for n == 0 
Towers of Hanaoi

Reference.