Use of recursion for repetitive algorithms

Recursions are very simple and they are very useful to make your code cleaner.

As in the screenshot below we can observe that a recursion occurs when you use a function within the same function. It may sound weird and tricky but after you see the example you will notice that it’s not that difficult.

In this case the recursion is used in order to get to the more simple values and it works as a loop that stop until it get to the last value.

CC BY 4.0 Use of recursion for repetitive algorithms by Jorge Padilla is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.