Skip to content

Instantly share code, notes, and snippets.

@charliebritton
Last active May 8, 2018 11:51
Show Gist options
  • Save charliebritton/3270a198ef578210816fb1232a6095f5 to your computer and use it in GitHub Desktop.
Save charliebritton/3270a198ef578210816fb1232a6095f5 to your computer and use it in GitHub Desktop.
function sumOfPrimes(number) {
let currentTotal = 0;
let mostRecentPrime = 0;
for(var i =1; i < number; i++) {
let factors = [];
for(var j = 1; j <= i; j++) {
if(i % j == 0) { factors.push(j) }
}
console.log("Factors:" + factors);
if(factors.length == 2) { currentTotal += i; mostrecentPrime = i }
console.log(mostrecentPrime, currentTotal)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment