Determine prime numbers within a specific range.
<?php
function primenumber($MyNum) {
$n = 0;
for($i = 2; $i < ($MyNum/2+1); $i++) {
if($MyNum % $i == 0){
$n++;
break;
}
}
if ($n == 0){
echo $MyNum." ";
}
}
$x = 1;
$y = 100;
echo "Prime numbers between ".$x." and ".$y." are: \n";
for($i = $x; $i < $y + 1; $i++) {
primenumber($i);
}
?>
Output