Check Abundant Number

Check whether a number is abundant (sum of proper divisors is greater than the number).

PythonBeginner
Python
# Program to check abundant number

num = int(input("Enter a positive integer: "))

if num <= 0:
    print("Number must be positive.")
else:
    total = 0
    for i in range(1, num):
        if num % i == 0:
            total += i

    if total > num:
        print(num, "is an abundant number")
    else:
        print(num, "is not an abundant number")

Output

Enter a positive integer: 12
12 is an abundant number

An abundant number has sum of proper divisors greater than the number itself. We reuse the divisor-summing pattern and compare with num.