Honaker primes: Difference between revisions

Added XPL0 example.
(Added XPL0 example.)
Line 650:
 
and the 10,000th: (286,069, 4,043,749)
</pre>
 
=={{header|XPL0}}==
<syntaxhighlight lang "XPL0">
func IsPrime(N); \Return 'true' if N is prime
int N, I;
[if N <= 2 then return N = 2;
if (N&1) = 0 then \even >2\ return false;
for I:= 3 to sqrt(N) do
[if rem(N/I) = 0 then return false;
I:= I+1;
];
return true;
];
 
func DigSum(N); \Return sum of digits in N
int N, S;
[S:= 0;
while N do
[N:= N/10;
S:= S + rem(0);
];
return S;
];
 
int N, C, H;
[Format(5, 0);
N:= 3; C:= 1; H:= 0;
loop [if IsPrime(N) then
[C:= C+1;
if DigSum(N) = DigSum(C) then
[H:= H+1;
if H<=50 or H=10000 then
[RlOut(0, float(C));
Text(0, ": ");
RlOut(0, float(N));
if rem(H/5) = 0 then CrLf(0) else Text(0, " ");
if H = 10000 then quit;
];
];
];
N:= N+2;
];
]</syntaxhighlight>
{{out}}
<pre>
32: 131 56: 263 88: 457 175: 1039 176: 1049
182: 1091 212: 1301 218: 1361 227: 1433 248: 1571
293: 1913 295: 1933 323: 2141 331: 2221 338: 2273
362: 2441 377: 2591 386: 2663 394: 2707 397: 2719
398: 2729 409: 2803 439: 3067 446: 3137 457: 3229
481: 3433 499: 3559 508: 3631 563: 4091 571: 4153
595: 4357 599: 4397 635: 4703 637: 4723 655: 4903
671: 5009 728: 5507 751: 5701 752: 5711 755: 5741
761: 5801 767: 5843 779: 5927 820: 6301 821: 6311
826: 6343 827: 6353 847: 6553 848: 6563 857: 6653
286069: 4043749
</pre>
 
297

edits