Last active
May 8, 2018 11:51
-
-
Save charliebritton/3270a198ef578210816fb1232a6095f5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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