I'm working on a Euler problem and am trying to build a function that checks a number to see if its a prime. I get error messages about the line:
if (a)%(b)==0{
Is my syntax wrong or is it impossible to use % on a variable rather on an integer?
var x = Math.sqrt(600851475143);
var y = Math.round(x);
y++;
console.log(y);
//find all of the prime numbers up to the square root number. Put them in an array.
//Check each ascending number against the prime numbers in the array to see if %=0
var primes = [2,3];
var a =(3);
while (a<y){
a++;
isPrime(a)
}
function isPrime(arr){
for (var i = 0; i < arr.length; i++){
var b = primes[i];
//next line is a problem
if (a)%(b)==0{
break
}else{
primes.push(a);
}
}
}