Skip to content

Instantly share code, notes, and snippets.

@jonrandy
Last active May 31, 2022 03:34
Show Gist options
  • Save jonrandy/56bcd63d83788bbae39515cdabc27f5b to your computer and use it in GitHub Desktop.
Save jonrandy/56bcd63d83788bbae39515cdabc27f5b to your computer and use it in GitHub Desktop.
isPrime using regex
const isPrime = x=>!'1'.repeat(x).match(/^1?$|^(11+?)\1+$/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment