A number is abundant if the sum of its proper divisors (all positive divisors excluding the number itself) is greater than the number. For example, 12 is abundant because its proper divisors are 1, 2, 3, 4, and 6, which sum to 16, and 16 is greater than 12. Write a method that returns true if the given number is abundant, and false otherwise. Return false for numbers less than or equal to 0, and false for null input.
Examples:
Input: n = 12
Output: true
Explanation: Proper divisors are 1, 2, 3, 4, 6 which sum to 16, and 16 > 12
Input: n = 18
Output: true
Explanation: Proper divisors are 1, 2, 3, 6, 9 which sum to 21, and 21 > 18
Input: n = 6
Output: false
Explanation: Proper divisors are 1, 2, 3 which sum to 6, and 6 is not greater than 6
Input: n = 7
Output: false
Explanation: Proper divisors are 1 only, which sums to 1, and 1 is not greater than 7
Input: n = null
Output: false
Explanation: Null input returns false
Apex Code Editor
Welcome to Lightning Challenge!
How It Works
- • Write your solution in the code editor
- • Connect your Salesforce org to test
- • Submit to check if your solution passes
- • Use hints if you get stuck
Contest Alert
🏆 #CodeEveryDay July 2026
Contest runs July 1 - 31. Complete challenges to climb the leaderboard!
Only the 31 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.