Sunday, 2 August 2015

Program to find prime numbers in PHP

Program to find prime numbers in PHP

<?php
//Program to find prime numbers in php

$counts =19;

for( $a = 2; $a <= $counts; $a++ )
{
for( $s = 2; $s < $a; $s++ )
{
if( $a % $s == 0 )
{
break;
}

}
if( $s == $a )
echo “Prime Number : “, $a, “<br>”;
}
?>

HERE IS THE OUTPUT

Prime Number : 2
Prime Number : 3
Prime Number : 5
Prime Number : 7
Prime Number : 11
Prime Number : 13
Prime Number : 17
Prime Number : 19