Monday 24 March 2014

Week 7: Recursion for realz this time

You just keep doing it over and over again.
Essentially recursion is a function that calls itself in order to complete whatever task you desire.

In order to use recursion there has to be:

  • a pattern or specific sequence that repeats it self.
  • a base case so the computer knows where to start.
  • a function that does something

The concept of recursion is not too difficult to understand, but its not as simple as it looks.
This stuff gets pretty confusing when you have some whacky sequence. 

Creating a recursive function ezpz once you get the base case, luckily if you're good with recognizing patterns you can get that base case. Unfortunately I am not that person.

 Here for some examples.
    

    Next example:
    

No comments:

Post a Comment