Avatar ·

Recursionerror: Maximum Recursion Depth Exceeded - How to overcome?

📁 Advanced Python Topics, question, Useful Tips and Lifehacks, AI

There is a task in; There is a solution, where, by the grace of Python, "defeated" "C#, but recursionerror flies out at x = 512: What do you advise, fathers? How to overcome, if you want to calculate for x = 1024, say?

   import  functools  from  math  import  sqrt @functools.lru_cache ()   def   f  ( x ):  if  x & lt; =  1 :  return   0   return   1  +  min  ([f + x // m -