A program that displays checks prime numbers by using parameters
Prime numbers using c# and parameters
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Biswa Pujarini MohapatraRank #465 · 5.4K reputationPosted Feb 7, 2014, 9:50 AM EST
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;
}
Shweta LodhaRank #31 · 39.8K reputationPosted Feb 7, 2014, 11:24 AM EST
{
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;
}
Shweta LodhaRank #31 · 39.8K reputationPosted Feb 8, 2014, 11:21 PM EST
If it worked, please mark is as an Answered/Accepted.