Quick actions

cmd+k|ctrl+k

Navigation

Languages

kaprekarNumbers 🙀

Snippet info

Language

Python

Visibility

public

Author

krishnakanth

Created

2023-05-24T14:20:25.181017Z

Updated

2023-05-24T14:20:25.181017Z

def kaprekarNumbers(p, q):
    # Write your code here
    res = []
    for i in range(p,q+1):
        temp = str(i*i)
        for j in range(len(temp)-1):
            if (int(temp[:j+1])+int(temp[j+1:]) == i) and (int(temp[:j+1]) != 0 and int(temp[j+1:]) != 0):
                res.append(i)
                print(temp[:j+1],temp[j+1:],"num:",i)
        # print(temp)
kaprekarNumbers(1000,10000)   
INFO