Pandigital prime: Difference between revisions
→{{header|C#|CSharp}}: modified for 1..7 / 0..7
m (added a Prime Numbers category.) |
(→{{header|C#|CSharp}}: modified for 1..7 / 0..7) |
||
Line 137:
=={{header|C#|CSharp}}==
<lang csharp>using System;
class Program {
// Find the highest pandigital number in base 10,
// Since the sum-of-digits of the pandigital numbers
// divisible by 3 and therefore always composite), we will only be looking at pandigital numbers
static void
var sw = System.Diagnostics.Stopwatch.StartNew();
// The difference between every permutation is a multiple of 9. To check odds only,
// start at XXXXXX1 or XXXXXX01 and decrement by 18.
//
for (int x = sp == '1' ? 7654321 : 76543201; ; x -= 18) {
// Tests for pan-digitality of x
//
// other required digits
var s = x.ToString();
for (var ch =
// Multi-factor test
// There is no check for even numbers since starting on an odd number and stepping by an even number
if (x % 3 == 0) continue;
for (int i = 1; i * i < x; ) {
if (x % (i += 4) == 0) goto
if (x % (i += 2) == 0) goto
}
sw.Stop(); Console.
}
}
static void Main(string[] args) {
fun('1');
fun('0');
}
}</lang>
{{out
<pre>
0..7: 76,540,231 24.5 ns</pre>
=={{header|Factor}}==
|