A positive integer n is abundant when the sum of its proper divisors is strictly greater thann. Proper divisors are positive divisors of n except n itself.
Remember
sum(proper divisors of n) > n → abundant
Example: 12 → 1+2+3+4+6 = 16 > 12 → abundant
Compare:
deficient → sum < n
perfect → sum == n
abundant → sum > n
n
Proper divisors
Sum
Result
12
1+2+3+4+6
16
Abundant
28
1+2+4+7+14
28
Perfect
10
1+2+5
8
Deficient
1
none
0
Not abundant
Approach
How to Check an Abundant Number in JavaScript
Four clear steps — then pick a basic or O(√n) loop.
Reject n <= 1.
Sum every proper divisor of n.
Return whether that sum is strictly greater than n.
Use a loop to n / 2 for clarity, or divisor pairs to √n for speed.
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
O(√n)
Larger n, optimizations
Pseudocode
Pseudocode
function IsAbundant(n):
if n <= 1:
return false
sum = 0
for i from 1 to n / 2:
if n mod i == 0:
sum = sum + i
return sum > n
Reference
Cheat Sheet
Keep these facts handy while writing the program.
Topic
Detail
Test
sum(proper divisors) > n
Proper divisors
Positive divisors of n except n
Basic loop
i = 1 .. n/2
Smallest
12
Perfect
sum equals n (e.g. 28)
Deficient
sum less than n (e.g. 10)
1..50
12 18 20 24 30 36 40 42 48
Try it
Live Preview
Enter a positive integer to see its proper divisors, their sum, and the verdict.
Positive whole numbers. Tap a chip or type a value.
Result
n = 12
Proper divisors: 1, 2, 3, 4, 6
Sum = 16
Verdict: ABUNDANT (16 > 12)
Code
JavaScript Programs
Start with the clear loop to n/2. Then list a range, and finish with the faster √n pair method. Each example has a Try it Yourself editor.
Example 1 — Check One Number
Sum proper divisors with a loop to num / 2, then compare with num.
JavaScript
function isAbundant(num) {
if (num <= 1) {
return false;
}
let sum = 0;
for (let i = 1; i <= Math.floor(num / 2); i++) {
if (num % i === 0) {
sum += i;
}
}
return sum > num;
}
const number = 12;
if (isAbundant(number)) {
console.log(number + " is an abundant number.");
} else {
console.log(number + " is not an abundant number.");
}
Loop i from 1 to num / 2 — no proper divisor is larger.
Add every i that divides num.
For 12 the sum is 16, so sum > num is true.
Return that comparison as a boolean.
Example 2 — Abundant Numbers from 1 to 50
Reuse the helper and print every match on one line.
JavaScript
function isAbundant(num) {
if (num <= 1) {
return false;
}
let sum = 0;
for (let i = 1; i <= Math.floor(num / 2); i++) {
if (num % i === 0) {
sum += i;
}
}
return sum > num;
}
console.log("Abundant numbers between 1 and 50 are:");
let line = "";
for (let i = 1; i <= 50; i++) {
if (isAbundant(i)) {
line += i + " ";
}
}
console.log(line.trim());
Abundant numbers between 1 and 50 are:
12 18 20 24 30 36 40 42 48
How It Works
Outer loop visits every integer from 1 to 50.
Each value is tested with the same isAbundant helper.
Matches are collected into one space-separated line.
The first hit is 12 — a useful self-check.
Keeping the helper pure makes range listing easy.
Example 3 — Sum Divisor Pairs up to √n
For each factor i, also add n / i, but never add n itself.
JavaScript
function isAbundant(num) {
if (num <= 1) {
return false;
}
let sum = 1;
for (let i = 2; i * i <= num; i++) {
if (num % i === 0) {
sum += i;
if (i !== num / i) {
sum += num / i;
}
}
}
return sum > num;
}
console.log(isAbundant(12)); // true (abundant)
console.log(isAbundant(28)); // false (perfect)