Above code will generate error saying, RecursionError: maximum recursion depth exceeded in comparison as this will continue the recursion steps infinitely.
In our real life situation we can imagine by placing one object between two parallel mirrors. This will generate infinite number of images.
Recursion in python to call the same function again with getrecursionlimit() & setrecursionlimit()
Getting and setting recursion limits
To stop the recursion to happen infinite times, Python provides one setting to allow maximum recursion steps to execute. This setting value we can read by using getrecursionlimit(). By default this value is set at 1000. We can change this limit by using setrecursionlimit(). Here is the code.
In our code we will use one condition to create a situation to come out of the recursion and return to the calling process. Here in this code as long as the value of n is equal to or more than 0 , the recursive call to the same function is executed. So this code will print from 5 till 0.
if (n >=0):