Once and For All, What Is Recursion??? (No Fibonacci/Factorial)

Gilat Blumberger
6 min readApr 27, 2021
Photo by Sebastian Herrmann on Unsplash

When I started learning how to code, as most developers to be, I encountered the term “recursion”. It was hard for me to put my head around it and every time I tried to google more about it I kept on seeing the Fibonacci or factorial of n examples over and over again. It frustrated me because it didn’t help me see the full potential of recursion or to understand other use cases.

Why should we bother?

Recursion is a good technique to implement when we have a solution to a sub-problem that could help us solve a bigger problem in a clean way. If you are interviewing to a technical role you should probably get yourself familiar with the concept, as it’s being asked often. Personally, I feel like I only fully understood the concept of iteration after figuring out recursion.

Photo by JESHOOTS.COM on Unsplash

When shouldn’t we use recursion?

It’s usually not the most optimal solution as it can create a stack overflow, and simply takes a lot of memory to generate many calls in the call stack. Most often a simple loop could be more efficient.

--

--

Gilat Blumberger
Gilat Blumberger

Written by Gilat Blumberger

Full Stack Software Developer. Love learning new things and now also write about them! 💪🏻

No responses yet