For our first example of recursion, let’s take a look at how to compute the factorial of a number. A factorial of a number, n, is defined by n! and it is the result of multiplying the numbers from 1 to n.
The factorial of 5 is represented by 5! and it is equal to 5 * 4 * 3 * 2 * 1, resulting in 120.