Skip to content

Instantly share code, notes, and snippets.

@CharlesAMoss
Created June 24, 2016 21:11
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 CharlesAMoss/53f7a3e469b380963db9b325fd2ecfbf to your computer and use it in GitHub Desktop.
Save CharlesAMoss/53f7a3e469b380963db9b325fd2ecfbf to your computer and use it in GitHub Desktop.
const isPrime = N => {
return (N > 1) && Array.apply(0, Array(1 + ~~Math.sqrt(N))).
every((x, y) => (y < 2) || (N % y !== 0));
}
const primeTime = N => ([...Array(N).keys()].filter(isPrime));
primeTime(10);
// output [2,3,5,7]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment