Skip to content

Instantly share code, notes, and snippets.

@arvindsvt
Last active February 26, 2018 15:33
Show Gist options
  • Save arvindsvt/31e770f0a5d0809bc6beef7b95325294 to your computer and use it in GitHub Desktop.
Save arvindsvt/31e770f0a5d0809bc6beef7b95325294 to your computer and use it in GitHub Desktop.
<?php
error_reporting(E_ALL);
$num =23;
for( $j = 2; $j <= $num; $j++ )
{
for( $k = 2; $k < $j; $k++ )
{
if( $j % $k == 0 )
{
break;
}
}
if( $k == $j )
echo 'Prime Number : ', $j, ';
}
?>
<?php
function IsPrime($n)
{
for($x=2; $x<$n; $x++)
{
if($n %$x ==0)
{
return 0;
}
}
return 1;
}
$a = IsPrime(3);
if ($a==0)
echo 'This is not a Prime Number.....'."\n";
else
echo 'This is a Prime Number..'."\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment