Abundant, deficient and perfect number classifications: Difference between revisions
(Add ref.) |
m (mention the special case at 1 in the definition of proper divisors.) |
||
Line 2: | Line 2: | ||
These define three classifications of positive integers based on their [[Proper divisors|proper divisors]]. |
These define three classifications of positive integers based on their [[Proper divisors|proper divisors]]. |
||
Let P(n) be the sum of the proper divisors of n, where the proper divisors of n are all perfect divisors of n less than n. |
Let P(n) be the sum of the proper divisors of n, where the proper divisors of n are all perfect divisors of n less than n unless n is 1. |
||
* if P(n) < n then n is classed as '''deficient'''. |
* if P(n) < n then n is classed as '''deficient'''. |
||
* if P(n) == n then n is classed as '''perfect'''. |
* if P(n) == n then n is classed as '''perfect'''. |
Revision as of 21:50, 16 December 2014
These define three classifications of positive integers based on their proper divisors.
Let P(n) be the sum of the proper divisors of n, where the proper divisors of n are all perfect divisors of n less than n unless n is 1.
- if P(n) < n then n is classed as deficient.
- if P(n) == n then n is classed as perfect.
- if P(n) > n then n is classed as abundant.
Example: 6 has proper divisors 1, 2, and 3. 1 + 2 + 3 = 6 so 6 is classed as a perfect number.
- Task
Calculate how many of the integers 1 to 20,000 inclusive are in each of the three classes and show the result here.
- Cf.
Python
Importing Proper divisors from prime factors: <lang python>>>> from proper_divisors import proper_divs >>> from collections import Counter >>> >>> rangemax = 20000 >>> >>> def pdsum(n): ... return sum(proper_divs(n)) ... >>> def classify(n, p): ... return 'perfect' if n == p else 'abundant' if p > n else 'deficient' ... >>> classes = Counter(classify(n, pdsum(n)) for n in range(1, 1 + rangemax)) >>> classes.most_common() [('deficient', 15042), ('abundant', 4953), ('perfect', 5)] >>> </lang>