Program for Prime number in PHP

Programming.jpg

A number that is merely divisible by 1 and itself is named a major number. Numbers 2, 3, 5, 7, 11, 13, 17, etc. are prime numbers.

2 is that the only even prime.

It is a number greater than 1 then 0 and 1 aren't prime numbers.

So, there are total 25 prime numbers up to 100. Therefore, the prime numbers 1 to 100 are often listed as, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97.

Program for Prime number in PHP

<?php  
$count = 0;  
$num = 2;  
while ($count < 15 )  
{  
$div_count=0;  
for ( $i=1; $i<=$num; $i++)  
{  
if (($num%$i)==0)  
{  
$div_count++;  
}  
}  
if ($div_count<3)  
{  
echo $num." , ";  
$count=$count+1;  
}  
$num=$num+1;  
}  
?>