• + 0 comments
    def primeFactors(n):
         
        # Print the number of two's that divide n
        a = []
        while n % 2 == 0:
            a.append(2)
            n = n // 2
             
        # n must be odd at this point
        # so a skip of 2 ( i = i + 2) can be used
        for i in range(3,int(math.sqrt(n))+1,2):
             
            # while i divides n , print i and divide n
            while n % i== 0:
                a.append(i)
                n = n // i
                 
        # Condition if n is a prime
        # number greater than 2
        
        if n > 2:
            a.append(n)
        return a
    def sum_of_digits(n):
        s=0
        while(n!=0):
            s+=n%10
            n=n//10
        return s
    
    def solve(n):
        # Write your code here
        a=primeFactors(n)
        s = 0
        for i in range(len(a)):
            if a[i] <10:
                s+=a[i]
            else:
                s+=sum_of_digits(a[i])
        s1 = sum_of_digits(n)
        if s1 == s:
            return 1
        else:
            return 0