Skip to content

Python RecursionError: maximum recursion depth exceeded while calling a Python object. This occurs when a recursive function calls itself too many times, exceeding the interpreter's maximum recursion depth.

Notifications You must be signed in to change notification settings

Bug-Hunter-X/RecursionError-in-Python-Factorial-Function-v5c78

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

RecursionError in Python Factorial Function

This example demonstrates a common error in Python: the RecursionError. It occurs when a recursive function calls itself infinitely, exceeding Python's maximum recursion depth. The factorial function below correctly calculates factorials for non-negative integers, but it fails for negative input.

The solution involves adding a base case to handle the invalid negative input, gracefully handling the error instead of letting it crash the program.

About

Python RecursionError: maximum recursion depth exceeded while calling a Python object. This occurs when a recursive function calls itself too many times, exceeding the interpreter's maximum recursion depth.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages