Skip to content

Instantly share code, notes, and snippets.

@SourceCode
Created December 21, 2015 06:09
Show Gist options
  • Save SourceCode/6a7ed6ca0269594c1129 to your computer and use it in GitHub Desktop.
Save SourceCode/6a7ed6ca0269594c1129 to your computer and use it in GitHub Desktop.
Prime Number Challenge
<?php
function primeNumber($n)
{
if ($n % 2 == 0) return false;
for ($i = 3; $i <= sqrt($n); $i += 2)
{
if ($n % $i === 0) return false;
}
return true;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment