Logic Building
# Find abundant numbers
print("Abundant numbers 1-100:")
for num in range(1, 101):
divisor_sum = 0
for i in range(1, num):
if num % i == 0:
divisor_sum += i
if divisor_sum > num:
print(num, end=" ")
print()Output
Abundant numbers 1-100: 12 18 20 24 30 36 40 42 48 54 ...
Check if sum of proper divisors exceeds number.
Key Concepts:
- Find all proper divisors
- Sum them
- Compare with number