title: Time Limit exceeded in python solution
body: <p>I was trying to solve the Leetcode question <a href="https://leetcode.com/problems/happy-number/" rel="nofollow noreferrer">Happy Number</a> and I seem to be stuck in a weird Time Limit Exceeded Error.</p>
  
  <p>My code:</p>
  
  <pre><code>class Solution:
      def isHappy(self, n: int) -&gt; bool:
          def simu(n):
              sums = 0
              while n&gt;0:
                  s = n%10
                  n = n//10
                  sums=sums+(s**2)
              if sums != 1:
                  simu(sums)
              return True
          while True:
              try:
                  return simu(n)
              except RecursionError:
                  return False
  </code></pre>
  
  <p>Any idea how to overcome this?</p>