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:

  1. 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
  2. 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?

results matching ""

    No results matching ""