Recursion : Understand recursion with a simple example

 Lets start with a general definition :

“Recursion occurs when a thing is defined in terms of itself or of its type. Recursion is used in a variety of disciplines ranging from linguistics to logic. The most common application of recursion is in mathematics and computer science, where a function being defined is applied within its own definition.”

Did it makes sense ? No ? Thats OK! Let the geek explain you the concept in a simple manner :

 At the board members have asked the CEO to prepare a presentation on company’s achievements, failures and a complete roadmap based on the earlier discussions. 


CEO is very happy about the overall performance and excited to present it to the board members. The only problem is the presentation is not prepared, and it will take a week for him to prepare it alone. After giving a thought, he called up his team and asked them to prepare a presentation and he would just added his own slides. The work begins…

 Soon , all the managers started calling their leads for the same. Leads asked junior members in the team to prepare the slides for their work. Finally junior members, started collaborating on a presentation.

 For each team, junior members started completing their work and pass it on to their leads. Leads would do the same and pass it on to their managers. Similarly, at each level employees completed their work and passed it on to their bosses. Finally, a presentation including all the slides from all the teams reached the CEO. CEO was pretty happy with the presentation, and he added his own slides.

Now a presentation was ready to be shared with the board of directors.

So what did you observe in the overall process ? Which was the common task which was recursively performed and ultimately the bigger task got completed ? 

Obviously , the answer is “Prepare a presentation” .

Now, lets compare this with recursion in computer science.

 Below is a simple program for finding the fibonacci sum for a given number :

int Fibonacci(int n) // starts with CEO level
    if (n == 0)
        return 0;
    else if (n == 1) // junior member , who does not have any employee under him. So he completes his task.
        return 1;
        return (Fibonacci(n - 1) + Fibonacci(n - 2)); // result from the teams is used by the managers to prepare 

 So in general, a given task is called recursively to perform a bigger operation. Recursion has a lot of applications in computer science and hence very important.

Hope this article was helpful. Thanks for visiting.

Kindly share your valuable feedback below. Like/share our page. This will help us improving.

In case its a query, kindly post it and we will get back to you ASAP.


Kaivalya Apte

2 thoughts on “Recursion : Understand recursion with a simple example

  1. Hi, I am David from and

    I really want to thank you for this post, I am going to share it on all my social media, if you do not mind!

    I am also really enthusiast to announce some very exciting news: to celebrate the imminent release of Spring 5 and Java 9 we launched our simulators SALE CAMPAIGN. We halved the price of our simulators at and for limited time only.

    If the audience is interested in accessing our price offer, they can take a look here and here

    Thanks and stay tuned for your featuring on our social medias!



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s