python solution for Happynumber


  • 0
    Y

    '''
    def Happynum(n):
    sum1=0
    while n>=10:
    sum1+=(n%10)2
    n = n//10
    sum1+=n
    2
    return sum1

    class Solution(object):
    def isHappy(self, n):
    """
    :type n: int
    :rtype: bool
    """
    list1=[]
    sum1 = Happynum(n)
    while sum1!=1:
    sum1=Happynum(sum1)
    list1.append(sum1)
    if list1.count(sum1)>1:
    return False
    else:
    return True
    '''


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.