Tell us what’s happening:
Whats the bug?
Your code so far
function getDPA(num){
let deficient = 0, perfect = 0, abundant = 0;
for(let i = 1; i <= num; i++){
if(sumOfDivisors(i) == i) perfect++;
else if(sumOfDivisors(i) < i) deficient++;
else abundant++;
}
return [deficient, perfect, abundant];
}
function sumOfDivisors(num){
let sum = 0; for(let i = 1; i < num; i++){if(num % i == 0) sum += i}
return sum;
}
console.log(getDPA(20000));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36
.
Link to the challenge: