# getDPA :Abundant, deficient, and perfect number classifications: Solution Submission

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`);
//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

Why store then only to sum them? Why not sum as you go?

``````function sumProperDivisors(n) {
let total = 0;
// Check each possible divisor
for (let i = 1; i < n; i++) {
if (n % i === 0) {
total += i;
}
}
}

function getDPA(n) {
let deficient = 0, perfect = 0, abundant = 0;

for (let j = 1; j <= n; j++) {
const propDiv = sumProperDivisors(j);
// Classify the number
if (propDiv < j) {
deficient++;
} else if (propDiv === j) {
perfect++;
} else {
abundant++;
}
}

return [deficient, perfect, abundant];
}
``````