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 C 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 | int (0/1) / text | 1 / message when sum of proper divisors > n. |
function isAbundant(n):
if n <= 1:
return false
sum = 0
for i from 1 to floor(n / 2):
if n mod i == 0:
sum = sum + i
return 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 | for (i = 1; i <= num / 2; ++i) |
| Abundant test | sum > n |
| Perfect test | sum == n |
| Deficient test | 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 C 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 num / 2, then compare with num.
#include <stdio.h>
int isAbundant(int num) {
if (num <= 1) {
return 0;
}
int sum = 0;
for (int i = 1; i <= num / 2; ++i) {
if (num % i == 0) {
sum += i;
}
}
return sum > num;
}
int main(void) {
int number = 12;
if (isAbundant(number)) {
printf("%d is an abundant number.\n", number);
} else {
printf("%d is not an abundant number.\n", number);
}
return 0;
} Guard num <= 1, then accumulate every i that divides num. Returning sum > num (as 1/0) 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.
#include <stdio.h>
int isAbundant(int num) {
if (num <= 1) {
return 0;
}
int sum = 0;
for (int i = 1; i <= num / 2; ++i) {
if (num % i == 0) {
sum += i;
}
}
return sum > num;
}
int main(void) {
printf("Abundant numbers between 1 and 50 are: ");
for (int i = 1; i <= 50; ++i) {
if (isAbundant(i)) {
printf("%d ", i);
}
}
printf("\n");
return 0;
} 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.
#include <stdio.h>
/* Returns 1 if num is abundant, 0 otherwise */
int isAbundant(int num) {
if (num <= 1) {
return 0;
}
int sum = 1;
for (int i = 2; i * i <= num; ++i) {
if (num % i == 0) {
sum += i;
if (i != num / i) {
sum += num / i;
}
}
}
return sum > num;
}
int main(void) {
printf("%d\n", isAbundant(12));
printf("%d\n", isAbundant(28));
return 0;
} Start sum at 1, then for each i from 2 while i * i <= num add both sides of the pair when they differ. Because the loop starts at 2, partner num / i is never num itself. 12 is abundant (1); 28 is perfect, so the second call prints 0.
If n <= 1, return 0 immediately — not abundant under this definition.
Add every proper divisor found by the basic loop or the pair method.
Test 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 | 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 isAbundant(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.
isAbundant vs properDivisorSum — pick names that match what the function returns.
Assert 12 returns 1, while 6, 28, and 7 return 0 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 0 — no positive proper-divisor sum beats n.
Only proper divisor is 1, so the sum cannot exceed n.
Sum equals n — return 0 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.
sum - n; abundant numbers have positive abundance.Try these variations to lock in the pattern.
"deficient", "perfect", or "abundant"n and 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.
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 ancient Greeks classified numbers as deficient, perfect, or abundant based on whether the sum of proper divisors was less than, equal to, or greater than the number. 6 is perfect (1+2+3 = 6); 12 is the smallest abundant number.
Learn how two numbers can each equal the proper-divisor sum of the other.
9 people found this page helpful