• + 0 comments

    def luckyNumbers(a, b): lucky_nums=[] seq=range(a,b+1) for num in seq: number=num sum=0 sum_sqr=0 while num!=0: remain=num%10 sum+=remain sum_sqr+=(remain**2) num=num//10

        count1=0
        for i in range(1,sum+1):
            if(sum%i==0):
                count1+=1
    
        count2=0
        for j in range(1,sum_sqr+1):
            if(sum_sqr%j==0):
                count2+=1
        if count1==2 and count2==2:
            lucky_nums.append(number)
    
    return len(lucky_nums)