A program that displays checks prime numbers by using parameters
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Shweta LodhaPosted Feb 9, 2014, 4:21 AM
If it worked, please mark is as an Answered/Accepted.
Shweta LodhaPosted Feb 7, 2014, 4:24 PM
{
if ((number & 1) == 0)
{
if (number == 2)
{ return true; }
else
{ return false; }
}
for (int i = 3; (i * i) <= number; i += 2)
{
if ((number % i) == 0)
{ return false; }
}
return number!= 1;
}
Biswa Pujarini MohapatraPosted Feb 7, 2014, 2:50 PM
static bool IsPrimeNumber(int num)
{
bool bPrime = true;
int factor = num / 2;
int i = 0;
for (i = 2; i <= factor; i++)
{
if ((num % i) == 0)
bPrime = false;
}
return bPrime;
}