Skip to content

Instantly share code, notes, and snippets.

@llzes
Created March 19, 2017 00:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save llzes/f2c55b5c57befb183013fa2f4bf4b4a1 to your computer and use it in GitHub Desktop.
Save llzes/f2c55b5c57befb183013fa2f4bf4b4a1 to your computer and use it in GitHub Desktop.
Returning the prime numbers between the smallest and biggest prime number provided.
/* This should take in whatever small prime
and whatever bigger prime number you want
and return the numbers in-between. */
var smallPrime=638489;
var bigPrime=697399;
function primeNumbers(countTo){
for(var i=smallPrime; i<countTo; i++){
if(countTo%i===0){
return false;
}
}
return true;
}
function smallToBigNumPrimeTest(bigNum){
var primeList = [smallPrime];
for(var i=smallPrime;i<bigNum;i+=2){
if(primeNumbers(i)){
primeList.push(i);
}
}
console.log(primeList);
}
smallToBigNumPrimeTest(bigPrime);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment