In all recursivity you have a starting point, the base case (trivial case) and the recursive case.
In this example, the base case is when you have one single element in the array to inspect. In the recursion you must advance a bit in each call and them combine the results from the recursive call with previous results.
Let's see how it works for the definition of factorial(n):
- Starting point: n
- base case: factorial(1) = 1
- recursive case: call factorial(n-1), multiply result by n and return it.
Applying this knowledge to our example we would have:
- starting point: the first position in the array
- trivial case: examine last element in the ...