Set an upper limit on the number of recursive function iterations in Python

If the recursive function is implemented in Problem on AtCoder, it will be RE (Runtime Error). .. .. The cause was that the upper limit of the number of repetitions of the recursive function was set to 1000 by default. ※Python3.4.3

[in]  import sys
[in]  sys.getrecursionlimit()
[out] 1000

Solution

[in]  sys.setrecursionlimit(1000000) #Set the upper limit to 1 million times
[in]  sys.getrecursionlimit()
[out] 1000000

You need to be careful when implementing recursive functions in Python. ..

Recommended Posts

Set an upper limit on the number of recursive function iterations in Python
[Python] Let's reduce the number of elements in the result in set operations
Get the number of readers of a treatise on Mendeley in Python
Output the number of CPU cores in Python
Get the caller of a function in Python
Visualize the timeline of the number of issues on GitHub assigned to you in Python
How to get the number of digits in Python
Get the size (number of elements) of UnionFind in Python
An easy way to pad the number with zeros depending on the number of digits [Python]
Note: The meaning of specifying only * (asterisk) as an argument in the Python function definition.
Analyzing data on the number of corona patients in Japan
Have the equation graph of the linear function drawn in Python
Get the number of specific elements in a python list
[Homology] Count the number of holes in data with Python
About the upper limit of threads-max
Count the number of Thai and Arabic characters well in Python
A function that measures the processing time of a method in python
[Python] I tried to summarize the set type (set) in an easy-to-understand manner.
The story of an error in PyOCR
The story of making Python an exe
OR the List in Python (zip function)
Check the in-memory bytes of a floating point number float in Python
[Python] Calculate the number of digits required when filling in 0s [Note]
[Python3] Rewrite the code object of the function
Associate the table set in python models.py
The result of installing python in Anaconda
[Question] In sk-learn random forest regression, an error occurs when the number of parallels is set to -1.
The basics of running NoxPlayer in Python
Open an Excel file in Python and color the map of Japan
The eval () function that calculates a string as an expression in python
In search of the fastest FizzBuzz in Python
Set the process name of the Python program
Project Euler # 17 "Number of Characters" in Python
An example of the answer to the reference question of the study session. In python.
plot the coordinates of the processing (python) list and specify the number of times in draw ()
Set the number of elements in a NumPy one-dimensional array to a power of 2 (0 padded)
I installed Pygame with Python 3.5.1 in the environment of pyenv on OS X
You will be an engineer in 100 days --Day 33 --Python --Basics of the Python language 8
You will be an engineer in 100 days --Day 26 --Python --Basics of the Python language 3
Let's automatically display the lyrics of the song being played on iTunes in Python
Divides the character string by the specified number of characters. In Ruby and Python.
In Python, change the behavior of the method depending on how it is called
You will be an engineer in 100 days --Day 32 --Python --Basics of the Python language 7
I want to get the file name, line number, and function name in Python 3.4
You will be an engineer in 100 days --Day 28 --Python --Basics of the Python language 4
Draw a graph of a quadratic function in Python
[Python] Sort the list of pathlib.Path in natural sort
Match the distribution of each group in Python
Calculate the total number of combinations with python
Make a copy of the list in Python
Find the number of days in a month
Install the python package in an offline environment
Find the divisor of the value entered in python
Fix the argument of the function used in map
Find the solution of the nth-order equation in python
The story of reading HSPICE data in Python
[Note] About the role of underscore "_" in Python
About the behavior of Model.get_or_create () of peewee in Python
Solving the equation of motion in Python (odeint)
Output in the form of a python array
I implemented the inverse gamma function in python