Powered by Blogger.

Prime Number Program in PHP



Prime Number Program in PHP

A prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself. Here we write Prime Number Program in PHP in very simple and easy way

PHP Code to Print Prime Number

<?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 "Not a Prime Number.....'."\n";
}
else
{
echo "Prime Number..'."\n";
}
?>  

I hope this code is helpful for you.



facebook
google-plus
twitter
pinterest

No comments :

Post a Comment

HTML Tutorial

images

About Sitesbay

This blog is related to Java Tutorial, C++ Tutorial, C Tutorial, Online Earning tips and more in very simple and easy way. Here i will try to give complete idea related to all new technology.

Java Tutorial

Java is Object oriented programming language, It is more secure and high performance language.

C++ Tutorial

C++ is also Object oriented programming language, It is more simple and easy to learn.

 
https://sitesbay.blogspot.com/?utm_medium=d2898efa59afcc0bc411921036e22b767ca37b09