Skip to content

Instantly share code, notes, and snippets.

@kadimi
Last active November 6, 2015 16:56
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 kadimi/a58c7c0c778a5d0ecc8e to your computer and use it in GitHub Desktop.
Save kadimi/a58c7c0c778a5d0ecc8e to your computer and use it in GitHub Desktop.
is_prime_number.php
<?pphp
/**
* Check if a number is a prime number
* @param int $n The number.
* @retun boolean True if $n is a prime number, false otherwise.
*/
function is_prime_number($n) {
$is_prime = true;
$max_count = ceil($n/2);
for($i=2; $i<$max_count; $i++) {
if($n%$i==0) {
$is_prime = false;
break;
}
}
return $is_prime;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment