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!

Create an Account

Sign up to track your progress, earn points, and compete with others. Your solutions will be saved automatically.

Create account

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 Mar/April 2026

Contest runs March 3 - April 30. Complete challenges to climb the leaderboard!

Points are calculated for challenges completed during the contest period.