for n in range(1, 101): item = [] s = 0 i = 1 while i <= n / 2: if n % i == 0: item.append(i) s = s + i i = i + 1 if s == n : print(s, item)