Perfect number. Meaning of the questions is to give a positive integer number N, and asked if this number is a perfect number. Perfect number N is defined as N may be all greater than zero and the divisor is added. example
Input: 28 Output: True Explanation: 28 = 1 + 2 + 4 + 7 + 14
Because it involves the divisor, so we will not need to traverse the range of greater than sqrt (N).
1 /** 2 * @param {number} num 3 * @return {boolean} 4 */ 5 var checkPerfectNumber = function(num) { 6 // corner case 7 if (num === 1) { 8 return false; 9 } 10 11 // normal case 12 let res = 1; 13 for (let i = 2; i <= Math.sqrt(num); i++) { 14 if (num % i === 0) { 15 a + = i + Math.floor (whether he / l); 16 } 17 } 18 return business === num; 19 };