Check Abundant Number in Python

Beginner
⏱️ 12 min read
📚 Updated: May 2026
🎯 2 Code Examples
Number theory

What you’ll learn

  • What an abundant number means in easy words.
  • How to find proper divisors and their sum.
  • One Python program to check a single number and one to print a range.
  • Common edge cases, interview tips, and complexity.

Overview

A number is abundant if its proper divisors add up to more than the number itself. This page shows the exact steps and gives clean Python code you can explain in school or interviews.

Quick examples

12Abundant
Proper divisors
1, 2, 3, 4, 6
Sum
16 > 12
6Perfect
Proper divisors
1, 2, 3
Sum
6 = 6
7Not abundant
Proper divisors
1
Sum
1 < 7

Live preview

Type a number to see its proper divisors and final verdict.

Use whole numbers n ≥ 1.

Live result
Press "Run check" to see details.

Algorithm

Goal: find the sum of proper divisors and check if that sum is greater than n.

Handle tiny values

If n <= 1, return false.

Start sum at zero

Create div_sum = 0.

Scan divisors

Loop from 1 to n // 2. If n % i == 0, add i to div_sum.

Compare

If div_sum > n, it is abundant; otherwise it is not.

📜 Pseudocode

Pseudocode
function isAbundant(n):
    if n <= 1:
        return false

    div_sum = 0
    for i from 1 to floor(n / 2):
        if n mod i == 0:
            div_sum = div_sum + i

    return div_sum > n
1

Check one number

python
def is_abundant(num: int) -> bool:
    if num <= 1:
        return False

    div_sum = 0
    for i in range(1, num // 2 + 1):
        if num % i == 0:
            div_sum += i

    return div_sum > num


number = 12
if is_abundant(number):
    print(f"{number} is an abundant number.")
else:
    print(f"{number} is not an abundant number.")
2

Print abundant numbers from 1 to 50

python
def is_abundant(num: int) -> bool:
    if num <= 1:
        return False

    div_sum = 0
    for i in range(1, num // 2 + 1):
        if num % i == 0:
            div_sum += i

    return div_sum > num


print("Abundant numbers between 1 and 50 are:")
for value in range(1, 51):
    if is_abundant(value):
        print(value, end=" ")

❓ FAQ

A positive integer n is abundant when the sum of its proper divisors is greater than n. Example: 12 is abundant because 1+2+3+4+6 = 16, and 16 > 12.
Proper divisors are positive divisors smaller than the number itself. For 18, proper divisors are 1, 2, 3, 6, and 9.
No. 1 has no positive proper divisors, so the sum is 0, which is not greater than 1.
No. A prime p only has proper divisor 1, so the sum is 1 and cannot be greater than p.
No proper divisor of n can be larger than n/2. So checking beyond n//2 is unnecessary in the simple approach.
Start with the simple method (easy to understand), then mention the sqrt optimization using divisor pairs for better performance.

Edge cases

n <= 1

Return False

These are not abundant in this tutorial definition.

Prime n

Always not abundant

Primes have only one proper divisor (1).

Large n

Use sqrt optimization

For very large values, divisor-pair logic is faster than scanning to n//2.

⏱️ Time and space complexity

ApproachTimeExtra space
Basic loop to n//2O(n)O(1)
Divisor pairs up to sqrt(n)O(√n)O(1)

Summary

  • Definition: abundant means sum of proper divisors is greater than the number.
  • Code: loop through divisors, add them, compare with n.
  • Interview tip: explain both basic and sqrt methods.
Did you know?

The smallest abundant number is 12 because its proper divisors are 1, 2, 3, 4, 6 and their sum is 16, which is greater than 12.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful