Prime number Program in php
by saddam
<?php
$sam=11;
for( $j = 2; $j <= $sum; $j++ )
{
for( $k = 2; $k < $j; $k++ )
{
if( $j % $k == 0 )
{
break;
}
}
if( $k == $j )
echo “Prime no is: “, $j, “<br>”;
}
?>
output:-
Prime no is:2;
Prime no is:3;
Prime no is:5;
Prime no is:7;
Prime no is:11;
by saddam
<?php
$sam=11;
for( $j = 2; $j <= $sum; $j++ )
{
for( $k = 2; $k < $j; $k++ )
{
if( $j % $k == 0 )
{
break;
}
}
if( $k == $j )
echo “Prime no is: “, $j, “<br>”;
}
?>
output:-
Prime no is:2;
Prime no is:3;
Prime no is:5;
Prime no is:7;
Prime no is:11;
Comments
Post a Comment