Skip to content

Instantly share code, notes, and snippets.

@vlas-ilya
Created October 9, 2015 16:21
Show Gist options
  • Save vlas-ilya/93947aede2da9d360481 to your computer and use it in GitHub Desktop.
Save vlas-ilya/93947aede2da9d360481 to your computer and use it in GitHub Desktop.
var isPrime = function (n) {
for (var i = 2; i < n; i++) {
if (n % i == 0) {
return false;
}
}
return true;
}
var sumPrimes = function (x) {
var result = 0;
for (var i = 2; i <= x; i++) {
if (isPrime(i)) {
result += i;
}
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment