Mathematics
Algorithms
Numbers

You can declare Array with running numbers up by using [...Array(n).keys]. Then if you want it start from 1, you just increase array size then slice it of.

Code
Diff
  • const isPerfect = n => 
      [...Array(n).keys()].slice(1).filter(e => !(n % e)).reduce((a, b) => a + b) === n
  • 11
    const isPerfect = n => 
    
    2
      Array(n - 1).fill(1).map((e, i) => e + i).filter(e => n % e === 0).reduce((a, b) => a + b) === n
    
    2+
      [...Array(n).keys()].slice(1).filter(e => !(n % e)).reduce((a, b) => a + b) === n