RECURSION

RECURSION

What is Recursion?

Recursion is the process of defining a problem (or the solution to a problem) in terms of (a simpler version of) itself.

A Recursive Function like the one in the picture is a function that calls itself. Recursive functions are very useful to solve many mathematical problems, such as calculating the factorial of a number, generating Fibonacci series, etc. But while using recursion, programmers need to be careful to define an exit condition from the function, otherwise it will go into an infinite loop.

Below you will find a cartoon dialog that ilustrates how the recursive function works:

No hay texto alternativo para esta imagen
No hay texto alternativo para esta imagen
No hay texto alternativo para esta imagen

If you still don't understand the concept this video may help you:

Hope you learn how to use recursion and take advantage of it as it helps you optimize code.

To view or add a comment, sign in

More articles by Paulina Crespi

  • What happens when you type google.com in your browser and press Enter

    Step 1: You type google.com(URL) into the address bar of your browser.

  • Internet of Things (IoT)

    What does IoT stand for? IoT stands for Internet of Things. It makes reference to the network of physical objects wich…

    1 Comment
  • Dynamic Libraries vs Static Libraries

    Why using libraries in general? Libraries provide the user the benefit to use a variety of functiones coded in…

  • What happens when you type `ls -l *.c` in the shell

    INTRODUCTION: A Unix shell is a command-line interpreter or shell that provides a command line user interface for…

  • ALL ABOUT C STATIC LIBRARIES

    What is a Library? A library is a collection of code routines (functions, classes, variables, and so on) that can be…

  • COMPILATION

    All the softwares, programs, websites and apps are written in a certain programming language. Basically, everything we…

  • HARD & SYMBOLIC LINKS IN LINUX

    What is a Hard Link? A hard link is merely an additional name for an existing file on Linux or other Unix- like…

Explore content categories