text: 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}