Abundant and Deficient Classifier - Problem
Given a positive integer, classify it as abundant, deficient, or perfect based on the sum of its proper divisors.
Definitions:
- Proper divisors: All positive divisors of a number except the number itself
- Abundant: Sum of proper divisors > number
- Deficient: Sum of proper divisors < number
- Perfect: Sum of proper divisors = number
Additionally, find and list the first 20 numbers of each type.
For a single number classification, return the classification as a string. For finding the first 20 of each type, return an object with arrays for each classification.
Input & Output
Example 1 — Perfect Number
$
Input:
n = 6
›
Output:
perfect
💡 Note:
Proper divisors of 6 are [1, 2, 3]. Sum = 1 + 2 + 3 = 6, which equals the number itself, so 6 is perfect.
Example 2 — Abundant Number
$
Input:
n = 12
›
Output:
abundant
💡 Note:
Proper divisors of 12 are [1, 2, 3, 4, 6]. Sum = 1 + 2 + 3 + 4 + 6 = 16, which is greater than 12, so 12 is abundant.
Example 3 — Deficient Number
$
Input:
n = 8
›
Output:
deficient
💡 Note:
Proper divisors of 8 are [1, 2, 4]. Sum = 1 + 2 + 4 = 7, which is less than 8, so 8 is deficient.
Constraints
- 1 ≤ n ≤ 106
- n is a positive integer
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code