Last active
January 1, 2019 22:11
-
-
Save birchb/c10903015d39f43f77648719c3df6c40 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
let primes = [ ] | |
const findNextPrime = (primeArray) => { | |
let foundPrime = false | |
for(np = 2; !foundPrime; np++) { | |
let isPrime = true | |
while(isPrime){ | |
for(p = 0; p < primeArray.length; p++) { | |
if (np % primes[p] == 0) { | |
isPrime = false | |
break | |
} | |
} | |
if (isPrime == 1) { | |
foundPrime = 1 | |
return np | |
} | |
} | |
} | |
} | |
let newPrime = findNextPrime(primes) | |
console.log('newPrime: ', newPrime); | |
primes.push(newPrime) | |
console.log(primes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment