मराठी

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

Advertisements

प्रश्न

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

टीपा लिहा
Advertisements

उत्तर

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
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 7: Python functions - Evaluation [पृष्ठ ११२]
Advertisements
Share
Notifications



      Forgot password?
Use app×