<?php
$num =23;
for( $j = 2; $j <= $num; $j++ )
{
for( $k = 2; $k < $j; $k++ )
{
if( $j % $k == 0 )
{
break;
}
}
if( $k == $j )
echo "$j".",";
}
?>
Output: 2,3,5,7,11,13,17,19,23,
$num =23;
for( $j = 2; $j <= $num; $j++ )
{
for( $k = 2; $k < $j; $k++ )
{
if( $j % $k == 0 )
{
break;
}
}
if( $k == $j )
echo "$j".",";
}
?>
Output: 2,3,5,7,11,13,17,19,23,
No comments:
Post a Comment