What’s recursion ?

It’s like like an alarm clock.

There is a saying that states in case you want to know if you understand something you have to try explaining it to a child. This will show if you really master what you know. So I tried to challenge myself and explain recursion to my little cousin.

Photo by Catherine Huyhes from Unsplash

It’s like when you plan to go out with your friends and you set your phone’s alarm clock to wake you up in the morning. So that you make sure you don’t miss out chilling with them. In the morning, when this alarm clock starts ringing, it will keep repeating the ringtone for every 5 minutes and will not cut off ringing until you wake up to stop it. This is what we call recursion !
It is a function that calls itself, that is the repetition of the ringtone every 5 minutes, until the stop condition, which is you, makes it stop.

This example infact made my little cousin understand somehow recursion.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store