How to Write a Recrusive Function
Recursive functions are sometimes hard to write because we are not use to thinking about problems recursively. However, there are two things you should do:
- state the base case (aka easy case). what argument value will be the simplest case that you can possibly have for your problem? what should the result be given this simplest case
- state the recursive case. if you are given something other than the simplest case how can you simplify it to head towards the simplest case?