Recursion in programming.

Sergio Ramos
2 min readJul 5, 2021

--

Hello and welcome, today we are going to see a small explanation of a topic that we have possibly seen, I have listened to some use in our lives.

It is a somewhat complex issue to understand at first, however we will try to explain it in the best way in this article, if more detours we start.

First of all, we are going to clarify some concepts that we must understand.

What is recursion?

The process in which a function calls itself directly or indirectly is called recursion and the corresponding function is called as recursive function. Using recursive algorithm, certain problems can be solved quite easily.

Imperative languages define loop structures such as while and for that are used to perform repetitive tasks.

Some functional programming languages do not define loop structures but instead allow recursion by calling code repetitively.

Computability theory has shown that these two types of languages are mathematically equivalent, that is, they can solve the same types of problems, even though functional languages lack the typical while and for structures.

What is the Stack?

Stack memory is a memory usage mechanism that allows the system memory to be used as temporary data storage that behaves as a first-in-last-out buffer.

Note: we generally see this concept in low-level programming languages such as C or C ++, however it is a very important concept that we should not forget.

Once these issues are clear, let’s see an example with a recursive function.

At this point we will explain this function with drawings because everything is easier with drawings.

--

--

Sergio Ramos

Hi, I’m Sergio Ramos, a software developer constantly learning.