Skip to content

Instantly share code, notes, and snippets.

@missdeer
Created November 11, 2013 02:39
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 missdeer/7406915 to your computer and use it in GitHub Desktop.
Save missdeer/7406915 to your computer and use it in GitHub Desktop.
isPrime.js, regexp magic
function isPrime(i) {
var ones = "";
while(--i >= 0) ones += "1";
return !/^1?$|^(11+?)\1+$/.test(ones);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment