Skip to content

Instantly share code, notes, and snippets.

@1yx
Created January 4, 2017 05:47
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 1yx/ff613d7049df71da206c7acc99685e56 to your computer and use it in GitHub Desktop.
Save 1yx/ff613d7049df71da206c7acc99685e56 to your computer and use it in GitHub Desktop.
check prime number use regex back reference in Javascript.
module.exports = (n) => {
return '1'.repeat(n) !== '1'.repeat(n).match(/1?$|(11+?)\1+$/)[0];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment