Using the for Loop in PHP

<?php echo("Prime Numbers between 1 and 30<p>"); //For loop from 1 to 30 for($var=1;$var<30;$var++) { $ctr=0; for($k=2;$k<=$var/2;$k++) { $d=$var%$k; if ($d == 0) { $ctr=1; break; } } if($ctr==0) { echo($var); echo("<br>"); } } ?>
Continue reading…

Enjoyed this post? Share it!