Hi friends , i have some code for to find out whether the no is prime or not. but i want it in c# using the same logic.
int isPrime(int n) {
int c =0, s=0;
if (n == 1) { return 0; }
if (n == 2) { return 1; }
if (n % 2 == 0) { return 0; }
s = (int)sqrt( (double)n );
for (c=3; c < s; c+=2) {
if (n % c == 0) {return 0;}
}
return 1;
}
Thanks in advance.