Skip to content

Instantly share code, notes, and snippets.

@vitaly-t
Last active October 16, 2021 16:52
Show Gist options
  • Select an option

  • Save vitaly-t/280c6f925c1c2d7e55be609ee0fe938e to your computer and use it in GitHub Desktop.

Select an option

Save vitaly-t/280c6f925c1c2d7e55be609ee0fe938e to your computer and use it in GitHub Desktop.
import {generatePrimes} from 'primes-generator';
// there are 1,270,607 primes in the first 20mln:
const iterator = generatePrimes({boost: 1_270_607});
let a, lastValue = 0, count = 0;
const start = Date.now();
do {
a = iterator.next();
if (a.done) {
break;
}
count++;
lastValue = a.value;
} while (true);
console.log(`Duration: ${Date.now() - start}, count: ${count}, last prime: ${lastValue}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment