Sum of first 1000 primes
by LyndseyB
HTML
3682913
JavaScript
var arr = [1], i = 1, total = 0;
while(arr.length <= 1000) {
++i;
if(isPrime(i)) {
arr.push(i);
total+=i;
}
}
function isPrime(n) {
var x;
for(x=2;x<n;x++) {
if(n % x === 0) {
return false;
}
}
return true;
}
console.log(total);