Ans: A number is prime if it is divisible only by one and itself. (Ex: 2, 3, 5, 7, 11, 13, 17....etc)
Program:
<?php $num = 4; // <=== Replace desired number to check for ($i = 2; $i <= $num - 1; $i++) { if (bcmod($num, $i) == 0) { echo $num . " is not prime number :("; break; } } if ($num == $i) echo $num . " is prime number :)"; ?>
No comments:
Post a Comment