• + 0 comments

    def kaprekarNumbers(p, q): arr = [] if p == 1: arr.append(1) start = p if p >= 9 else 9 for i in range(start, q+1): left = str(i**2)[:-len(str(i))] right = str(i**2)[-len(str(i)):] if int(left) + int(right) == i: arr.append(i) print(*arr) if arr else print("INVALID RANGE")