How to set the limit for recursive function? Give an example.
Advertisements
Question
How to set the limit for recursive function? Give an example.
Advertisements
Solution
Python also allows you to change the limit using sys.setrecursionlimit (limit value).
Example:
import sys
sys.setrecursionlimit(3000)
def fact (n):
if n = = 0:
return 1
else:
return n * fact (n – 1)
print (fact (2000))
APPEARS IN
RELATED QUESTIONS
A Function which calls itself is called as ______
Which function is called anonymous un-named function?
Write the different types of functions.
Differentiate ceil() and floor() function?
Write a Python code to check whether a given year is a leap year or not.
What are the points to be noted while defining a function?
Explain the following built-in function.
id()
Explain the following built-in function.
round()
Explain the following built-in function.
type()
Explain the following built-in function.
pow()
