Descending primes: Difference between revisions

Content added Content deleted
(Added C# version)
Line 172: Line 172:
class Program {
class Program {


static bool ispr(uint n) {
static bool ispr(uint n) {
if ((n & 1) == 0 || n < 2) return n == 2;
if ((n & 1) == 0 || n < 2) return n == 2;
for (uint j = 3; j * j <= n; j += 2)
for (uint j = 3; j * j <= n; j += 2)
Line 193: Line 193:
else break;
else break;
}
}
Console.WriteLine("\n{0} decending primes found", c); c = 0;
Console.WriteLine("\n{0} descending primes found", c);
}
}
}</lang>
}</lang>
Line 215: Line 215:
8764321 8765321 9754321 9875321 97654321
8764321 8765321 9754321 9875321 97654321
98764321 98765431
98764321 98765431
87 decending primes found</pre>
87 descending primes found</pre>


=={{header|F_Sharp|F#}}==
=={{header|F_Sharp|F#}}==