Ask Your Question By Comment We Will Give You Better Solution Soon

Thursday 23 January 2014

Find Prime No in PHP

<?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,

No comments:

Post a Comment