Back to Practice Dashboard
Python BasicsEasy
Abundant number
Learn how to solve the 'Abundant number' problem. This detailed resource details brute force and optimized approaches.
Problem Statement
Easy
Write a function is_abundant(n) that takes a positive integer n and returns True if n is an abundant number, or False otherwise. An abundant number is a number where the sum of its proper divisors (all divisors excluding the number itself) is greater than the number.
Constraints
- •1 <= n <= 10^6
Examples
Example 1
Input
n = 12
Output
True
Explanation
Proper divisors of 12: 1, 2, 3, 4, 6. Sum = 16. Since 16 > 12, it is abundant.
Example 2
Input
n = 18
Output
True
Explanation
Proper divisors of 18: 1, 2, 3, 6, 9. Sum = 21. Since 21 > 18, it is abundant.
Example 3
Input
n = 7
Output
False
Explanation
Proper divisors of 7: 1. Sum = 1. Since 1 < 7, it is not abundant.
Need a Hint?
Use simple arithmetic operators (like modulo `%`, division `//`), conditional checks, or loops to inspect number properties.
Edge Cases to Watch
- Empty list or null input variables
- Single item lists/arrays
- Extremely large input bounds causing integer or stack overflow
Ready to Solve?
Open the problem in PyRun's browser-based Python editor. Your code runs fully offline — no server required.