Comments on Are they abundant, deficient or perfect?
Post
Are they abundant, deficient or perfect?
Abundant numbers are numbers which are less than their proper divisor sum. For example $18$ is abundant as $1 + 2 + 3 + 6 + 9 = 21 > 18$
Deficient numbers are numbers which are greater than their proper divisor sum. For example, $15$ is deficient as $1 + 3 + 5 = 9 < 15$
Perfect numbers are numbers wich are equal to their proper divisor sum. For example, $6$ is perfect as $1 + 2 + 3 = 6$.
You should take a positive integer $x \ge 12$ and output three lists. The lists should contain, in any order, the abundant numbers less than or equal to $x$, the deficient numbers less than or equal to $x$ and the perfect numbers less than or equal to $x$.
For example, if $x = 15$, the output could look like
[[12], [6], [1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 13, 14, 15]]
This is code golf, so the shortest code in bytes wins
Test cases
49 -> [[12, 18, 20, 24, 30, 36, 40, 42, 48], [6, 28], [1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 19, 21, 22, 23, 25, 26, 27, 29, 31, 32, 33, 34, 35, 37, 38, 39, 41, 43, 44, 45, 46, 47, 49]]
32 -> [[12, 18, 20, 24, 30], [6, 28], [1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 19, 21, 22, 23, 25, 26, 27, 29, 31, 32]]
16 -> [[12], [6], [1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 13, 14, 15, 16]]
29 -> [[12, 18, 20, 24], [6, 28], [1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 19, 21, 22, 23, 25, 26, 27, 29]]
23 -> [[12, 18, 20], [6], [1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 19, 21, 22, 23]]
[Husk], 10 bytes kSo±-ȯ …
3y ago
Vyxal `o`, 16 bytes …
3y ago
Vyxal, 30 28 25 bytes Saved …
3y ago
[APL (Dyalog Unicode)], 21 byt …
3y ago
BQN, 21 bytesSBCS ``` (¬·× …
3y ago
[Jelly], 6 bytes ÆṣṠ)Ġ …
3y ago
Japt, 11 bytes Could be 2 b …
3y ago
[Python 3], 235 185 141 118 by …
3y ago
1 comment thread