Rosetta Challenge: Abundant, deficient and perfect number classifications

Does the Rosetta coding challenge test for efficiency of the code (in terms of speed)? Because the tests for the same code if run on my local machine prove right. However, if run on the freeCodeCamp website give the wrong output.

getDPA(20000) results:

  • on my local machine: [ 15043, 4, 4953 ] (these are mentioned in the challenge as the correct output
  • on the freeCodeCamp website: [ 999, 3, 324 ] (these result keep changing every time i run them on the website and i’m confused why they aren’t giving the right results)

please help me find the error in my code :frowning:

My code so far

function getDPA (num) {
  let properDivisors = [];
  let classifier = [0, 0, 0];

  for(let n=1; n<=num; n++){
    let divisorSum = 0;

    for(let i=1; i<n; i++){
      if(n%i === 0)
        divisorSum += i
    if(divisorSum < n){
    }else if(divisorSum === n){

  console.log("This is DPA " + num);
  // console.table(getDPA(6));
  return classifier;

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36.

Link to the challenge: