A Collection of Code Snippets in as Many Programming Languages as Possible

This project is maintained by TheRenegadeCoder

Welcome to the Prime Number in Php page! Here, you'll find the source code for this program as well as a description of how the program works.

```
<?php
/**
* Function to determine if a number if prime.
* @param int positive integer.
* @return True if the number is prime, False otherwise.
*/
function is_prime($num)
{
if (($num % 2 == 0 && $num != 2) || ($num == 1)) {
return false;
}
$found_factor = false;
for ($n = 3; $n <= intval(ceil(sqrt($num))); ++$n) {
if (($num % $n) == 0) {
$found_factor = true;
break;
}
}
return !$found_factor;
}
// Check argument
if ($argc < 2 || !is_numeric($argv[1]) || strpos($argv[1], '.') !== false || strpos($argv[1], '-') !== false) {
echo "Usage: please input a non-negative integer\n";
exit(1);
}
// Convert the string
if (is_prime(intval($argv[1]))) {
echo "Prime\n";
} else {
echo "Composite\n";
}
exit(0);
```

Prime Number in Php was written by:

- Jeremy Grifski
- Juan D Frias
- Parker Johansen

If you see anything you'd like to change or update, please consider contributing.

No 'How to Implement the Solution' section available. Please consider contributing.

No 'How to Run the Solution' section available. Please consider contributing.