Understanding Recursive Functions

Scott Cosentino
Nov 5 · 4 min read

Recursion is a programming concept that involves a function or method calling itself continuously until it reaches some stopping condition. It can be looked at as a complementary operation to iteration. Often, we can substitute them with each other, replacing recursion with iteration and iteration with recursion, however, in some instances, recursion yields a cleaner solution when compared to iteration.

First, let’s discuss situations where recursion can work well over an iterative solution. Recursion is typically used in instances where the results of one iteration rely…

Keep the story going. Sign up for an extra free read.

You've completed your member preview for this month, but when you sign up for a free Medium account, you get one more story.
Already have an account? Sign in

Scott Cosentino

Written by

Computer programmer specializing in security. My blog: www.scprogramming.com

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade