Member-only story
Learn about Recursion Using Python
Learn how to use recursive functions to solve real-world problems.
Hi all, today we are going to talk about recursion, a very strange and difficult topic for most students in Computer Science programs. However, recursion is a tool that can make our lives easier in many cases. In this article we are going to cover the following topics:
1. Introduction & Motivation
2. Factorial Calculator (Pen and Paper)
3. Factorial Calculator using Python
4. Fibonacci series (Pen and Paper)
5. Fibonacci series using Python
6. ConclusionWe have a lot of work to do, so let’s get started.
Introduction & Motivation
First of all, Recursion is a process in which a function calls itself. The corresponding function is called the recursive function. Using recursive functions, we are able to solve certain problems, such as tree traversal, sort of arrays (Merge Sort, Quick Sort), etc. In recursion, we try to solve a problem by breaking it into smaller and simpler sub-problems. This technique is known as Divide and Conquer in Computer Science.
Αs we shall see later, instead of using recursion, we can use traditional iterative approaches to solve the same problem. However, by using recursive functions we make our code cleaner…







