Everyday Examples
Mathematical Examples
The factorial
function:
factorial(0) = 1 factorial(n) = n * factorial(n-1) [for n>0]Let's compute
factorial(3)
:
factorial(3) = 3 * factorial(2) = 3 * ( 2 * factorial(1) ) = 3 * ( 2 * ( 1 * factorial(0) )) = 3 * ( 2 * ( 1 * 1 ) )) = 6
Recursive Definition: base case(s) + recursive case