The factorial of N is defined recursively as follows: If N is zero then the value of N! is one. Otherwise, the value of N factorial is N times N-1 factorial.
0! = 1, N! = Nˇ(N-1)!.
If we tried this definition for N = 4, we would get the following sequence:
4! = 4ˇ3! First reentry (N=3) 3! = 3ˇ2! Second reentry (N=2) 2! = 2ˇ1! Third reentry (N=1) 1! = 1ˇ0! Fourth reentry (N=0) (and return) 0! = 1 Return from Third 1! = 1ˇ1 = 1 Return from Second 2! = 2ˇ1 = 2 Return from First 3! = 3ˇ2! = 3ˇ2 = 6 4! = 4ˇ3! = 4ˇ6 = 24
Because the number N is decreased at each "reentry", it is guaranteed to reach zero and terminate the sequence after a finite number of times. text