Question: programming logic to find whether the given number is prime or not in C or C#? 

Answer: While Sieve_of_Eratosthenes is good for finding all prime upto a power, it is not good for finding whether a given number is prime. In this case modulas method is good. But the algorithm of first answer is inefficien( because it checks upto x-1 while checking upto square root of x is sufficient).\nA better algorithm is\n\nint isPrime(x){\nfor(i=0;i<(int)sqrt(x);i++)\nif(x%i)==0 return 0;\n\nreturn 1;\n}
This question from the Yahoo Q&A forum is categorized in the topic: Health