Ascending primes: Difference between revisions
Content added Content deleted
Line 367: | Line 367: | ||
static bool isPrime(uint n) |
static bool isPrime(uint n) |
||
{ |
{ |
||
if (n == |
if (n == 2) |
||
⚫ | |||
⚫ | |||
return false; |
return false; |
||
uint root = (uint)Math.Sqrt(n); |
|||
for (uint k = 3; k <= root; k += 2) |
|||
if (n % |
if (n % k == 0) |
||
return false; |
return false; |
||
uint root = (uint)Math.Sqrt(n); |
|||
for (uint k = 3; k <= root; k += 2) |
|||
⚫ | |||
⚫ | |||
} |
|||
return true; |
return true; |
||
} |
} |