Primes with digits in nondecreasing order: Difference between revisions
Content added Content deleted
m (→{{header|Phix}}: s=sort(s) is much simpler than finding false in a sequence-comparison of slices!) |
m (→{{header|C#|CSharp}}: added base 16, limited output window size) |
||
Line 85: | Line 85: | ||
static void Main(string[] args) { int c, lim = 1000; string s; |
static void Main(string[] args) { int c, lim = 1000; string s; |
||
foreach (var b in new List<int>{ 2, 3, 4, 5, 6, 7, 8, 9, 10, 17, 27, 31, 62 }) { |
foreach (var b in new List<int>{ 2, 3, 4, 5, 6, 7, 8, 9, 10, 16, 17, 27, 31, 62 }) { |
||
ba = b; c = 0; foreach (var a in PG.Primes(lim)) |
ba = b; c = 0; foreach (var a in PG.Primes(lim)) |
||
if (nd(s = from10(a))) Write("{0,4} {1}", s, ++c % 20 == 0 ? "\n" : ""); |
if (nd(s = from10(a))) Write("{0,4} {1}", s, ++c % 20 == 0 ? "\n" : ""); |
||
Line 98: | Line 98: | ||
for (; j <= lim; j += 2) if (!flags[j]) yield return j; } }</lang> |
for (; j <= lim; j += 2) if (!flags[j]) yield return j; } }</lang> |
||
{{out}} |
{{out}} |
||
<pre> 11 111 11111 1111111 |
<pre style="height:20em"> 11 111 11111 1111111 |
||
Base 2: found 4 non-decreasing primes under 1111101000 |
Base 2: found 4 non-decreasing primes under 1111101000 |
||
Line 132: | Line 132: | ||
449 457 467 479 499 557 569 577 599 677 |
449 457 467 479 499 557 569 577 599 677 |
||
Base 10: found 50 non-decreasing primes under 1000 |
Base 10: found 50 non-decreasing primes under 1000 |
||
2 3 5 7 B D 11 13 17 1D 1F 25 29 2B 2F 35 3B 3D 47 49 |
|||
4F 59 67 6B 6D 7F 89 8B 9D AD BF DF EF 115 119 11B 125 133 137 139 |
|||
13D 14B 15B 15D 167 16F 17B 17F 18D 199 1AF 1BB 1CD 1CF 1DF 223 22D 233 239 23B |
|||
24B 257 259 25F 269 26B 277 28D 2AB 2BD 2CF 2DD 2EF 335 337 33B 33D 347 355 359 |
|||
35B 35F 36D 377 38B 38F 3AD 3DF |
|||
Base 16: found 88 non-decreasing primes under 3E8 |
|||
2 3 5 7 B D 12 16 1C 1E 23 27 29 2D 38 3A 3G 45 4B 4F |
2 3 5 7 B D 12 16 1C 1E 23 27 29 2D 38 3A 3G 45 4B 4F |