happy number by Pokolo.l

#!/usr/bin/python3\x0d
def nextNum(num):\x0d
   numStr = str(num)\x0d
   nextNum = 0\x0d
   for i in numStr:\x0d
      nextNum += int(i) ** 2\x0d
   return nextNum\x0d
\x0d
def isHappy(num):\x0d
   passed = []\x0d
   while num not in passed:\x0d
      passed.append(num)\x0d
      num = nextNum(num)\x0d
      if num == 1:\x0d
         return True\x0d
   return False\x0d
\x0d
for i in range(1, 2000):\x0d
   if isHappy(i):\x0d
      print(i)\x0d

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return top