happy number by Pokolo.l

def nextNum(num):\x0d
   numStr = str(num)\x0d
   nextNum = 0\x0d
   for i in numStr:\x0d
      nextNum += int(i) ** 2\x0d
   return nextNum\x0d
def isHappy(num):\x0d
   passed = []\x0d
   while num not in passed:\x0d
      num = nextNum(num)\x0d
      if num == 1:\x0d
         return True\x0d
   return False\x0d
for i in range(1, 2000):\x0d
   if isHappy(i):\x0d

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


return to the top page