Recursion
Recursion is a programming method we use in functional programming for imitating the functionality of a loop without having to define a loop. Instead we call the same function with different arguments from inside the function nearly before last line. Thus we execute the function again any time we are about to finish it.
In order to exit this recursive 'loop' we normally specify a condition that prevents code from further execution and from the function to call itself again.
Take a look at the code above and how the factorial function has been implemented again, this time recursively.
The function still accepts a number as before, but instead of looping from 1 to this number, we calculate the result (line 9) and then call the same function, this time with the number decreased by one. We do the same thing again and again until the number is 1. Then the if statement is executed and we return the result itself (remember return, also exits the function).