list1 = [] sum1 = 0 list2 = [10, 100, 1000, 10000] for num in range(10000, 100000): list1 = [(num // i) * (num % i) for i in list2] sum1 = sum(list1) if sum1 == num: print(num, end = ' ')