Definition
Sum > n
n is abundant when the sum of its proper divisors is strictly greater than n.
An abundant number has proper divisors that add up to more than the number itself. This tutorial covers the definition, a live preview, algorithm steps, worked Python examples, edge cases, and complexity.
Sum > n
n is abundant when the sum of its proper divisors is strictly greater than n.
Exclude n
Positive divisors smaller than n — for 12 that is 1, 2, 3, 4, and 6.
1 … n//2
Scan candidates up to n//2, add each divisor, then compare the sum to n.
Faster path
Walk i up to √n and add both i and n//i (skipping n itself) for O(√n) time.
Try any n
Type a number and see divisors, sum, and abundant / perfect / deficient verdict.
Complexity
Both approaches use O(1) extra space; pick the method that matches the interview ask.
An abundant number is a positive integer whose proper divisors add up to more than the number itself. The classic first example is 12: proper divisors 1 + 2 + 3 + 4 + 6 = 16, and 16 > 12.
In interviews you usually write a helper that sums proper divisors, then compare that sum with n. The same helper also classifies perfect numbers (sum equals n) and deficient numbers (sum is less than n).
It trains divisor loops, careful edge handling for 1 and primes, and a natural path to the O(√n) optimization interviewers love to hear.
Abundant needs sum > n — equality is perfect, not abundant.
No abundant number exists below 12 — a great sanity check.
Simple n//2 loop, or divisor-pair sum up to √n.
Primes only have proper divisor 1, so they are always deficient.
In short: sum the proper divisors of n; if that sum is greater than n, the number is abundant.
Given a positive integer n, decide whether it is abundant: whether the sum of its proper divisors is greater than n.
# Example: n = 12
# Proper divisors: 1, 2, 3, 4, 6
# Sum = 16 > 12 → abundant | Item | Type | Description |
|---|---|---|
n | int | Positive integer to classify (treat n ≤ 1 as not abundant). |
| Return / print | bool / text | True / message when sum of proper divisors > n. |
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 | Method | Idea | Time |
|---|---|---|
| Basic loop | Add every divisor from 1 to n // 2 | O(n) |
| Divisor pairs | Loop to √n; add both factors (skip n) | O(√n) |
| Goal | Pattern |
|---|---|
| Is divisor? | n % i == 0 |
| Basic upper bound | range(1, n // 2 + 1) |
| Abundant test | div_sum > n |
| Perfect test | div_sum == n |
| Deficient test | div_sum < n |
| Pair partner | n // i (add if i != n // i and partner ≠ n) |
All can decide abundance — clarity and speed differ.
1 .. n//2Easiest to explain; fine for small n and whiteboard demos
i & n//iSame answer in O(√n); mention this as the optimization
σ(n) > 2nEquivalent math: sum of all divisors exceeds 2n
explain bothLead with basic, then show the pair optimization
Reach for abundant-number drills when divisor sums and number classification matter.
Quick check of loops, modulo tests, and clear boolean returns.
Pairs naturally with perfect and deficient number questions.
Abundant checks share the same divisor-sum building block as amicable pairs.
Visible example (12) makes the “sum then compare” pattern stick.
Printing every abundant number to a huge limit needs smarter sieves — discuss that separately.
Key benefit: one small problem that covers divisors, classification, edge cases, and a clean O(√n) upgrade.
Type a positive integer to see its proper divisors, sum, and classification.
Three complete Python programs — check one number, list a range, and an O(√n) divisor-pair variant. Click View Output to reveal sample console results.
Classify a single integer with the basic loop.
Sum proper divisors with a loop to n // 2, then compare with n.
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.") Guard num <= 1, then accumulate every i that divides num. Returning div_sum > num is the entire definition of abundance.
Reuse the helper across a range.
Call the same check in a loop and print matches on one line.
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=" ") The helper stays pure; the outer loop only decides what to print. Notice the first hit is 12 — a useful self-check when you rewrite the function.
Same verdict in O(√n) using divisor pairs.
For each factor i, also consider n // i, but never add n itself.
import math
def is_abundant_fast(num: int) -> bool:
if num <= 1:
return False
div_sum = 1 # 1 is always a proper divisor for num > 1
limit = int(math.isqrt(num))
for i in range(2, limit + 1):
if num % i == 0:
div_sum += i
partner = num // i
if partner != i and partner != num:
div_sum += partner
return div_sum > num
print(is_abundant_fast(12))
print(is_abundant_fast(28)) Start with 1, then for each i from 2 to √n add both sides of the pair when they differ. Skip the partner when it equals num so you never include the number itself. 12 is abundant; 28 is perfect (sum = 28), so the second call is False.
If n <= 1, return false immediately — not abundant under this definition.
Add every proper divisor found by the basic loop or the pair method.
Test div_sum > n. Equality means perfect; less means deficient.
Return or print whether n is abundant based on that strict inequality.
n = 12Trace the basic method for 12. Loop i from 1 to 12 // 2 = 6 and add every divisor.
i | 12 % i | Action | div_sum |
|---|---|---|---|
1 | 0 | Add 1 | 1 |
2 | 0 | Add 2 | 3 |
3 | 0 | Add 3 | 6 |
4 | 0 | Add 4 | 10 |
5 | 2 | Skip | 10 |
6 | 0 | Add 6 | 16 |
Final check: 16 > 12 → abundant.
Where abundant-number checks (and their divisor sums) show up beyond the prompt.
Split integers into deficient, perfect, and abundant buckets.
Example: 7 / 6 / 12 in one helper.
Proper-divisor sums are the core of amicable-number checks.
Example: 220 and 284 share the same sum helper.
Shows loops, modulo, and optional sqrt optimization cleanly.
Example: “write is_abundant(n)” prompts.
Concrete numbers make “exclude n itself” easy to remember.
Example: chalkboard walkthrough of 12.
Several classic problems ask for sums over abundant numbers.
Example: non-abundant sums style tasks.
Compare O(n) vs O(√n) on the same boolean question.
Example: time both helpers on large n.
Pro Tip: keep one proper_divisor_sum(n) helper and derive abundant / perfect / deficient from it — less duplicated logic.
Why these approaches work well in interviews and classwork.
Sum proper divisors, compare with n — almost no translation gap.
You can start O(n) and upgrade to O(√n) without changing the problem statement.
The same function powers perfect, deficient, and amicable problems.
Both methods need only a few integers — O(1) extra space.
Pro Tip: say the definition out loud first, then code the sum — interviewers score clarity as much as the loop.
Small habits that keep abundant-number code interview-ready.
Proper divisors never include the number; looping only to n // 2 makes that automatic.
>Perfect numbers satisfy equality — do not treat them as abundant.
Return false for n <= 1 before any loop.
is_abundant vs proper_divisor_sum — pick names that match what the function returns.
Assert 12 is True, 6 and 28 are False, 7 is False before moving on.
Pro Tip: dry-run 12 on paper once — it catches off-by-one upper bounds faster than guessing.
Mistakes that commonly break abundant-number solutions.
Adding the number itself turns every n into “abundant” via sum ≥ n + 1.
→ Loop only to n // 2, or skip the partner when it equals n.
>= Instead of >That wrongly labels perfect numbers as abundant.
→ Abundance requires a strict greater-than comparison.
When i * i == n, adding both i and n // i counts the root twice.
→ Only add the partner when partner != i.
n <= 1 GuardEmpty ranges or awkward special cases can confuse beginners.
→ Return false early for tiny inputs.
A wrong sum that exceeds 1 for a prime is a bug, not a discovery.
→ Spot-check a few primes after coding.
Check these inputs before calling the solution done.
Return False — no positive proper-divisor sum beats n.
Only proper divisor is 1, so the sum cannot exceed n.
Sum equals n — return false for the abundant check.
Great golden test: must return true.
When using sqrt pairs, do not double-count the square root.
The basic loop to n//2 gets slow; switch to divisor pairs.
Handy facts interviewers sometimes ask as follow-ups.
div_sum - n; abundant numbers have positive abundance.Try these variations to lock in the pattern.
"deficient", "perfect", or "abundant"n and div_sum - n for each hitQuick Takeaway: sum proper divisors; if the sum is greater than n, the number is abundant.
| Program | Time | Extra space |
|---|---|---|
| Basic loop to n//2 | O(n) | O(1) |
| Divisor pairs up to √n | O(√n) | O(1) |
| Range scan 1…m (basic) | O(m²) worst case | O(1) |
Abundant numbers are a clean divisor-sum exercise: exclude n, add what remains, and test a strict greater-than comparison. Master the basic loop first, then explain the O(√n) pair method when interviewers ask about performance.
Practice the three examples above, then continue to amicable numbers — they reuse the same proper-divisor sum idea.
Never include n in the sum, never treat perfect numbers as abundant, and validate tiny inputs early.
div_sum > n (strict)n <= 1Classify integers the interview-friendly way.
Sum of proper divisors > n
DefinitionDivisors exclude n
MathLoop 1 … n//2
CodeDivisor pairs to √n
CodeO(n) or O(√n)
AnalysisThe 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.
Learn how two numbers can each equal the proper-divisor sum of the other.
9 people found this page helpful