A function that calls itself
Read · 1 of 4
Two parts
A recursive function solves a problem by solving a smaller version of the same problem, then finishing the job. 4! = 4 × 3!, and 3! = 3 × 2!, and so on.
It also needs a base case: a size so small the answer is known directly (1! = 1). Without it the calls never stop and the program crashes.