The Factorial Function

The factorial function is defined as:

F(n) = n(n - 1)(n - 2)(n - 3) ... (2)(1)
where n is a non-negative integer.
We define F(0) = 1 and F(1) = 1.

The factorial function F(n) is also represented as "n!", read "n factorial."


Examples.


5!=5(4)(3)(2)(1) = 120  
3!=3(2)(1) = 6  
10!=10(9)(8)(7)(6)(5)(4)(3)(2)(1) = 3628800  
0!=1;;(by definition)  
6!=6(5)(4)(3)(2)(1) = 720  


Example 1: If 6 children must form a line, in how many ways can they arrange themselves?

6 different children can stand in the first spot, 5 in the second spot (since 1 is already occupying the first spot), 4 in the third spot (since 2 are already occupying spots), etc.
Thus, they can arrange themselves in 6(5)(4)(3)(2)(1) = 6! = 720 different ways.

n! gives the number of ways n distinct items can be arranged in an order.


Example 2: In how many ways can the letters of the word TRIANGLE be arranged?

8! = 40320 different ways.