• + 0 comments
    def kaprekarNumbers(p, q):
        # Write your code here
        exists = False
        for n in range(p, q+1):
            d = len(str(n))
            n_quare = str(n * n)
            left, right = n_quare[:-d], n_quare[-d:]
            
            if int(left or 0) + int(right) == n:
                print(n, end=" ")
                exists = True
        if not exists:
            print("INVALID RANGE")