# Sum All Primes - Problem with big numbers

Sum All Primes - Problem with big numbers
0

#1

Tell us what’s happening:
I’m working on “Sum All Primes” Algorithm and have 2 working conditions for sumPrimes(10) but when it comes to sumPrimes(977) the result is way to high. I tried to go step by step over my code but have a trouble understanding what is wrong. Is my condition missing something?

``````
function sumPrimes(num) {
let primeArr = [2, 3, 5];
let sumPrimes = 0;
let condition = false;
// Build prime numbers arr
for(let i = 6; i <= num; i++) {
condition = !(i % 2 === 0 || i % 3 === 0);
if(condition) {
primeArr.push(i);
}
}
// Sum primeArr
for(let y = 0; y < primeArr.length; y++) {
sumPrimes += primeArr[y];
}
return sumPrimes;
}

sumPrimes(977);
``````

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36`.
You are putting a number in `primeArr` if it is not divisible by 2 or 3. That is not the definition of a prime number.