Check Abundant Number
Check whether a number is abundant (sum of proper divisors is greater than the number).
BeginnerTopic: Conditional Programs
Python Check Abundant Number Program
This program helps you to learn the fundamental structure and syntax of Python programming.
# 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
Understanding Check 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.
Note: To write and run Python programs, you need to set up the local environment on your computer. Refer to the complete article Setting up Python Development Environment. If you do not want to set up the local environment on your computer, you can also use online IDE to write and run your Python programs.