6 kyu

Abundant Array

63 of 167ThomasL

Description:

Your task is to return an array of the first n abundant numbers, sorted by their abundance. If the abundance is the same for multiple numbers, sort them numbers from smallest to largest.

"An abundant number or excessive number is a number for which the sum of its proper divisors is greater than the number itself. The integer 12 is the first abundant number. Its proper divisors are 1, 2, 3, 4 and 6 for a total of 16. The amount by which the sum exceeds the number is the abundance. The number 12 has an abundance of 4, for example."

For example:

  • 10 is not an abundant because the sum of its proper divisors is 8; 1+2+5=8.
  • 12 is an abundant number with an abundance of 4; 1+2+3+4+6=16, 16-12=4.
  • 18 is an abundant number with an abundance of 3; 1+2+3+6+9=21, 21-18=3.

The first 5 abundant numbers sorted by their abundance are [20, 18, 12, 24, 30]

Number Sum of Divisors Abundance
20 22 2
18 21 3
12 16 4
24 36 12
30 42 12

You will be given n, a number between 0 and 300 and must return an array of that length, and must do so within the test's time limit.

Fundamentals
Mathematics
Algorithms

More By Author:

Check out these other kata created by ThomasL

Stats:

CreatedOct 27, 2016
PublishedOct 27, 2016
Warriors Trained366
Total Skips10
Total Code Submissions936
Total Times Completed167
JavaScript Completions63
Python Completions114
Total Stars15
% of votes with a positive feedback rating97% of 72
Total "Very Satisfied" Votes67
Total "Somewhat Satisfied" Votes5
Total "Not Satisfied" Votes0
Total Rank Assessments5
Average Assessed Rank
5 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • ThomasL Avatar
  • smile67 Avatar
  • utoppia Avatar
  • saudiGuy Avatar
Ad