Prime Number :-
A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. For example, 3 is a prime number because it has no positive divisors other than 1 and 3.Prime numbers are below:-
2, 3, 5, 7, 11, 13, 17, 19 ....
<?php
function CheckPrime($number){
for($x=2;$x<$number;$x++){
if($number%$x == 0){
return 0;
}
}
return 1;
}
$a = CheckPrime(17);
if ($a==0)
echo 'This is not a Prime Number.....'."\n";
else
echo 'This is a Prime Number..'."\n";
?>
Output :- This is a Prime Number..
Using the above program you can check whether a number is prime or not in PHP.
Note: Only a member of this blog may post a comment.