Abundant Number Check
Find whether proper divisors sum to more than a positive integer. Students use a factor loop to distinguish abundant numbers from perfect and deficient ones.
1# Take number2num = int(input("Enter a number: "))34# Find sum of proper divisors5divisor_sum = 06for i in range(1, num):7 if num % i == 0:8 divisor_sum += i910# Check abundant11if num > 0 and divisor_sum > num:12 print("Abundant number")13else:14 print("Not an abundant number")
Output
Enter a number: 12 Abundant number
In this one
- Compare proper-divisor totals
- Recognize strict abundance
- Exclude negative inputs
How it works
- 1
Sum factors smaller than num.
- 2
Require num positive and the sum strictly greater.
- 3
Print the abundant or not-abundant result.
Edge cases
Is six abundant?
Is six abundant?
No. Equality is not enough.
Should negative numbers pass?
Should negative numbers pass?
No. The final test must require a positive input as well as a larger divisor sum.
What's going on
An abundant number has a proper-divisor sum strictly greater than itself. The loop scans positive integers below num and adds those that divide it exactly.
For twelve, factors one, two, three, four, and six total sixteen, so it passes. Six is perfect instead: its total equals six, which is not greater. This definition applies to positive integers, not negative inputs that can otherwise pass an empty-sum comparison.
Is six abundant? No. Equality is not enough.
Should negative numbers pass? No. The final test must require a positive input as well as a larger divisor sum.
Quiz
Tap an option. The answer stays hidden until you pick.
Question 1
Which input is abundant?
Pick an answer to check it.
Question 2
Is six abundant?
Pick an answer to check it.
Questions people ask
Is six abundant?
No. Equality is not enough.
Should negative numbers pass?
No. The final test must require a positive input as well as a larger divisor sum.
Which input is abundant?
12.
๐Related Content
- ๐
Phase 2 - Learn Concepts
Review Phase 2 concepts and explanations
- ๐
Phase 2 - Quiz
Test your Phase 2 understanding with quiz questions
- ๐ป
Phase 2 - All Practice Problems
Explore all practice problems for Phase 2
- ๐
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- ๐ง
Logic Building Overview
Learn about the complete logic building curriculum