Last active
December 19, 2015 00:49
Revisions
-
OpenGrid revised this gist
Jun 27, 2013 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ function getPrimes(howMany) { var primes = [], isPrime, primesCount = 0, candidate, primeIndex; for (candidate = 2; primesCount < howMany; candidate++) { for(primeIndex = 0, isPrime = true; primeIndex < primesCount && primes[primeIndex] <= Math.sqrt(candidate) && isPrime;) { -
OpenGrid revised this gist
Jun 27, 2013 . 1 changed file with 7 additions and 9 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,17 +3,15 @@ function getPrimes(howMany) { var isPrime, primesCount = 0, candidate, primeIndex; for (candidate = 2; primesCount < howMany; candidate++) { for(primeIndex = 0, isPrime = true; primeIndex < primesCount && primes[primeIndex] <= Math.sqrt(candidate) && isPrime;) { isPrime = (candidate % primes[primeIndex++] === 0) ? false : true; } if(isPrime === false) { continue; } primes[primesCount++] = candidate; } return primes; } -
OpenGrid revised this gist
Jun 26, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ function getPrimes(howMany) { var isPrime, primesCount = 0, candidate, primeIndex; for (candidate = 2; primesCount < howMany; candidate++) { for(primeIndex = 0, isPrime = true; primeIndex < primesCount && primes[primeIndex] <= Math.sqrt(candidate); primeIndex++) { if (candidate % primes[primeIndex] === 0) { isPrime = false; -
OpenGrid created this gist
Jun 26, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ function getPrimes(howMany) { var primes = []; var isPrime, primesCount = 0, candidate, primeIndex; for (candidate = 2; primesCount < howMany; candidate++) { for(primeIndex = 0, isPrime = true; primeIndex < primesCount, primes[primeIndex] <= Math.sqrt(candidate); primeIndex++) { if (candidate % primes[primeIndex] === 0) { isPrime = false; break; } } if(isPrime) { primes.push(candidate); primesCount++; } } return primes; }