Skip to content

Instantly share code, notes, and snippets.

@zeraphie
Created March 8, 2016 15:15
Show Gist options
  • Select an option

  • Save zeraphie/8c93834d7a405758e07b to your computer and use it in GitHub Desktop.

Select an option

Save zeraphie/8c93834d7a405758e07b to your computer and use it in GitHub Desktop.
Test if a number is prime 1-liner
function is_prime($number) {
return !preg_match('/^1?$|^(11+?)\1+$/x', str_repeat('1', $number));
}
@zeraphie

zeraphie commented Mar 8, 2016

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment