0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Pythonで再帰関数の繰り返し回数の上限を設定する

Posted at

AtCoder上の問題で再帰関数を実装していたらRE(RuntimeError)に。。。
原因は再帰関数の繰り返し回数の上限がデフォルトでは1000に設定されていたためでした。
※Python3.4.3

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

解決方法

[in]  sys.setrecursionlimit(1000000) #上限を100万回に設定
[in]  sys.getrecursionlimit()
[out] 1000000

Pythonで再帰関数を実装する時は気をつける必要がありますね〜。。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?