English
Tamil Nadu Board of Secondary EducationHSC Science Class 12

How to set the limit for recursive function? Give an example. - Computer Science

Advertisements
Advertisements

Question

How to set the limit for recursive function? Give an example.

Short/Brief Note
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))

shaalaa.com
Introduction to Python Functions
  Is there an error in this question or solution?
Chapter 7: Python functions - Evaluation [Page 112]

APPEARS IN

Samacheer Kalvi Computer Science [English] Class 12 TN Board
Chapter 7 Python functions
Evaluation | Q 7. | Page 112
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×