A positive integer n is abundant when its aliquot sum (sum of proper divisors) is strictly greater thann. The difference aliquotSum − n is called the abundance.
Remember
aliquotSum = sum of proper divisors of n
aliquotSum > n → abundant
abundance = aliquotSum − n
Proper divisors = positive divisors of n, except n itself
Example: 12 → 1+2+3+4+6 = 16 > 12 → abundant (abundance 4)
Class
Condition
Example
Deficient
divSum < n
7 → 1 < 7
Perfect
divSum == n
6 → 1+2+3 = 6
Abundant
divSum > n
12 → 1+2+3+4+6 = 16
First abundant numbers (1–50)
Handy checklist for interviews and unit tests — the first value must be 12.
List
12, 18, 20, 24, 30, 36, 40, 42, 48
Equivalent form: σ(n) > 2n, where σ(n) sums all positive divisors (including n).
Approach
How to Check an Abundant Number in C#
Four clear steps — then pick a basic or O(√n) loop.
Reject n <= 1.
Sum proper divisors (aliquot sum).
Compare with n using strict >.
Optionally report abundance sum − n or classify deficient / perfect / abundant.
Method
Idea
Time
Best for
Basic loop
Add every divisor from 1 to n / 2
O(n)
Interviews, small n
Divisor pairs
Loop to √n; add i and n / i (skip n)
O(√n)
Larger n, optimizations
Pseudocode
Pseudocode
function IsAbundant(n):
if n <= 1:
return false
divSum = 0
for i from 1 to floor(n / 2):
if n mod i == 0:
divSum = divSum + i
return divSum > n
Cheat sheet
Goal
Pattern
Is divisor?
n % i == 0
Basic bound
for (i = 1; i <= n / 2; i++)
Abundant test
divSum > n (strict)
Pair partner
n / i — add if i != n / i and partner ≠ n
Try it
Live Preview
Enter any positive integer to see proper divisors, sum, and classification.
Whole numbers n ≥ 1 (capped at 999999). Tap a chip or type a value.
Result
n = 12
Proper divisors (aliquot parts): 1, 2, 3, 4, 6
Aliquot sum = 16
Abundance = 16 − 12 = 4
Compare: 16 > 12
Verdict: ABUNDANT
Trace
Worked Walkthrough — n = 12
Basic method: loop i from 1 to 12 / 2 = 6. Add every i that divides 12.
i
12 % i
Action
divSum
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 with abundance 16 − 12 = 4. (12 is the smallest abundant number.)
Code
C# Programs
Three programs: check one number, classify with abundance + user input, and an O(√n) interview variant. Use View Output for sample results.
Example 1 — Check One Number
Sum proper divisors with a loop to n / 2, then return divSum > n.
C#
using System;
class Program
{
static bool IsAbundant(int num)
{
if (num <= 1)
{
return false;
}
int divSum = 0;
for (int i = 1; i <= num / 2; i++)
{
if (num % i == 0)
{
divSum += i;
}
}
return divSum > num;
}
static void Main()
{
int number = 12;
if (IsAbundant(number))
{
Console.WriteLine(number + " is an abundant number.");
}
else
{
Console.WriteLine(number + " is not an abundant number.");
}
}
}
Output
12 is an abundant number.
How It Works
1. Guard tiny inputs. Return false when num <= 1 — nothing below 2 is abundant.
2. Scan to half. Loop i from 1 to num / 2. No proper divisor can be larger than half of num.
3. Accumulate and compare. Add every divisor to divSum, then return divSum > num. For 12: 1+2+3+4+6 = 16, and 16 > 12.
Example 2 — Classify + Abundance (User Input)
Interview follow-up: print deficient, perfect, or abundant, plus abundance. Uses int.TryParse for safe input.
C#
using System;
class Program
{
static int AliquotSum(int num)
{
if (num <= 1)
{
return 0;
}
int divSum = 0;
for (int i = 1; i <= num / 2; i++)
{
if (num % i == 0)
{
divSum += i;
}
}
return divSum;
}
static void Main()
{
Console.Write("Enter a positive integer: ");
if (!int.TryParse(Console.ReadLine(), out int n) || n < 1)
{
Console.WriteLine("Please enter a positive integer.");
return;
}
int sum = AliquotSum(n);
int abundance = sum - n;
if (sum > n)
{
Console.WriteLine(n + " is abundant (abundance = " + abundance + ").");
}
else if (sum == n)
{
Console.WriteLine(n + " is perfect (abundance = 0).");
}
else
{
Console.WriteLine(n + " is deficient (abundance = " + abundance + ").");
}
}
}
Output (when user enters 12)
Enter a positive integer: 12
12 is abundant (abundance = 4).
How It Works
1. Safe input.int.TryParse avoids FormatException on bad text.
2. One sum, three labels. Compare sum to n: greater → abundant, equal → perfect, less → deficient.
3. Abundance.sum - n is positive for abundant, 0 for perfect, and negative for deficient. For 12: abundance 4. Expected abundant values up to 50: 12 18 20 24 30 36 40 42 48.
Example 3 — O(√n) with Divisor Pairs
For each factor i, also consider n / i — never add n, and do not double-count squares.
C#
using System;
class Program
{
static bool IsAbundantFast(int num)
{
if (num <= 1)
{
return false;
}
int divSum = 1; // 1 is always a proper divisor for num > 1
for (int i = 2; i * i <= num; i++)
{
if (num % i == 0)
{
divSum += i;
int partner = num / i;
if (partner != i && partner != num)
{
divSum += partner;
}
}
}
return divSum > num;
}
static void Main()
{
Console.WriteLine(IsAbundantFast(12)); // True (abundant)
Console.WriteLine(IsAbundantFast(28)); // False (perfect)
}
}
Output
True
False
How It Works
1. Seed with 1. Start divSum at 1 and begin the loop at 2.
2. Walk to √n. While i * i <= num, each factor i has a partner num / i.
3. Add carefully. Always add i. Add partner only when it differs from i and is not num. Same verdict as Example 1 — faster loop. Explain the basic method first in interviews.
Edge Cases & Pitfalls
Check these before calling the solution done.
n <= 1
Not abundant
Return false before any loop.
Include n?
Never add n
Including n wrongly makes almost every number look abundant.
>= vs >
Use strict >
>= wrongly labels perfect numbers (6, 28) as abundant.
Prime
Always deficient
Only proper divisor is 1 — sum cannot exceed n.
Perfect
6, 28, …
Sum equals n — IsAbundant must return false.
Squares
No double-count
In pair mode, add the root only once when i * i == n.
Analysis
Time and Space Complexity
Program
Time
Extra space
Basic loop to n/2
O(n)
O(1)
Divisor pairs up to √n
O(√n)
O(1)
Classify 1…m (basic)
O(m²) worst case
O(1)
Remember
Key Takeaways
Definition: aliquot sum > n; abundance = sum − n.
Exclude n: proper divisors never include the number itself.
Two loops: basic 1 … n/2, or pairs up to √n.
Test set: 12 true; 6 and 28 false; any prime false.
One line: compute the aliquot sum; if it exceeds n, the number is abundant (abundance = sum − n).
Frequently Asked Questions
A positive integer n is abundant when the sum of its proper divisors (aliquot sum) is greater than n. Example: 12 → 1+2+3+4+6 = 16, and 16 > 12.
Abundance is aliquotSum − n. For 12 it is 16 − 12 = 4. For a perfect number abundance is 0; for a deficient number it is negative.
The aliquot sum is another name for the sum of proper divisors — all positive divisors of n except n itself.
Proper divisors are positive divisors of n excluding n itself. For 18 they 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 has only proper divisor 1, so the sum is 1 and cannot exceed p.
Yes, but they are rare among small values. The smallest odd abundant number is 945. Every abundant number below that is even.
Perfect: sum equals n. Deficient: sum is less than n. Abundant: sum is greater than n. Every positive integer is exactly one of these three.
Start with the simple 1..n/2 loop, then show the O(√n) divisor-pair upgrade when asked to optimize.
Basic loop to n/2 is O(n). Divisor pairs up to √n is O(√n). Both use O(1) extra space.
🤔
Did you know?
The smallest abundant number is 12 (abundance 4). The smallest odd abundant number is 945 — almost all small abundants are even.