1// I will update this code later, cause this is already very tasky,
2// bad performance(Two loops inside a loop) // Very bad, but it works
3
4const sumPrimes = num => {
5 const divisor = []
6 for(let i = 2; i <= num; i++){
7 let factorial = [], j = 1, num = []
8 while(j <= i){ factorial.push(j); j++ }
9
10 factorial.forEach(elem => {
11 if(i % elem === 0) num.push(elem)
12 })
13
14 if(num.length === 2) divisor.push(i)
15 }
16
17 return divisor.reduce((acc, cur) => acc + cur);
18}
19
20sumPrimes(977);