Abundant Numbers
List abundant numbers from one through one hundred using Python. Students compare proper-divisor totals with their candidates and keep equality from abundance.
1# Find abundant numbers2print("Abundant numbers 1-100:")34for num in range(1, 101):5 divisor_sum = 06 for i in range(1, num):7 if num % i == 0:8 divisor_sum += i910 if divisor_sum > num:11 print(num, end=" ")12print()
Output
...
The sample abbreviates a longer result. The program prints the intervening values; it does not print these dots.
In this one
- Build proper-divisor sums
- Use a strict comparison
- Separate abundant from perfect
How it works
- 1
Reset divisor_sum for each candidate.
- 2
Add factors below the candidate itself.
- 3
Print only when the completed sum is larger.
Edge cases
Does six print?
Does six print?
No. It is perfect, not abundant.
Does twelve print?
Does twelve print?
Yes. Its proper-divisor sum is sixteen.
What's going on
For each num, the inner loop adds positive factors smaller than num. The completed total must strictly exceed num.
Twelve qualifies because one, two, three, four, and six total sixteen. Six does not, since equality makes it perfect rather than abundant. Resetting the accumulator per candidate prevents earlier divisor sums from affecting later classifications.
Does six print? No. It is perfect, not abundant.
Does twelve print? Yes. Its proper-divisor sum is sixteen.
Quiz
Tap an option. The answer stays hidden until you pick.
Question 1
Which comparison defines abundance?
Pick an answer to check it.
Question 2
Does six print?
Pick an answer to check it.
Questions people ask
Does six print?
No. It is perfect, not abundant.
Does twelve print?
Yes. Its proper-divisor sum is sixteen.
Which comparison defines abundance?
divisor_sum > num.
๐Related Content
- ๐
Phase 6 - Learn Concepts
Review Phase 6 concepts and explanations
- ๐
Phase 6 - Quiz
Test your Phase 6 understanding with quiz questions
- ๐ป
Phase 6 - All Practice Problems
Explore all practice problems for Phase 6
- ๐
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- ๐ง
Logic Building Overview
Learn about the complete logic building curriculum