happy number, test case issue
class Solution:
    def isHappy(self, n: int) -> bool:
        d={}
        while(n not in d):
            d[n]=1
            s = 0
            while(n):
                s += (n%10)**2
                n = n/10
            if(s==1):
                return 'true'            
            else:
                d[s]=1
                n=s
        return 'false'

This is the code I've written for happy number
Bt when I tried to submit it says wrong answer for input 2
I tested the same code on other platform with input as 2 and it returns false
can anyone help me with this

Comments (0)