What is your hint or solution suggestion?
function sumProperDivisors(n) {
let divArr = [];
for(let i = 1; i < n; i++) {
if(n%i == 0) {divArr.push(i);} }
//console.log(`divArr currently holds ${divArr}.\n`);
let divTot = divArr.reduce((el,tot) => { tot+= el; return tot;}, 0);
//console.log(`divTot is ${divTot}.\n`);
return divTot; }
function getDPA(n) {
let dCnt=0, pCnt=0, aCnt = 0, propDiv;
for(let j = 1; j <= n; j++) {
propDiv = sumProperDivisors(j);
if(propDiv < j) {dCnt++;}
if(propDiv == j) {pCnt++;}
if(propDiv > j) {aCnt++;}
}
//console.log(`deficient: ${dCnt}, perfect: ${pCnt},`+
//`abundant: ${aCnt}.\n`);
return [dCnt, pCnt, aCnt];
}
Challenge: Abundant, deficient and perfect number classifications
Link to the challenge: