Blum integer: Difference between revisions

Content added Content deleted
(→‎{{header|Go}}: Updated in line with Wren example of which it is a translation.)
(Added XPL0 example.)
Line 259: Line 259:
24.997% end in 7
24.997% end in 7
24.985% end in 9
24.985% end in 9
</pre>

=={{header|XPL0}}==
Simple minded brute force takes 93 seconds on Pi4.
<syntaxhighlight lang "XPL0">int Prime1;

func Semiprime(N); \Return 'true' if N is semiprime
int N, F, C;
[C:= 0; F:= 2;
repeat if rem(N/F) = 0 then
[C:= C+1;
Prime1:= N;
N:= N/F;
]
else F:= F+1;
until F > N;
return C = 2;
];

int N, C, Prime2;
[Format(4,0);
N:= 3; C:= 0;
loop [if Semiprime(N) then
[if rem(Prime1/4) = 3 then
[Prime2:= N/Prime1;
if Prime2 # Prime1 and rem(Prime2/4) = 3 then
[C:= C+1;
if C <= 50 then
[RlOut(0, float(N));
if rem(C/10) = 0 then CrLf(0);
];
if rem(C/1000)=0 then ChOut(0, ^.);
if C >= 26828 then
[Text(0, "^m^jThe 26828th Blum integer is: ");
IntOut(0, N); CrLf(0);
quit;
];
];
];
];
N:= N+2;
];
]</syntaxhighlight>
{{out}}
<pre>
21 33 57 69 77 93 129 133 141 161
177 201 209 213 217 237 249 253 301 309
321 329 341 381 393 413 417 437 453 469
473 489 497 501 517 537 553 573 581 589
597 633 649 669 681 713 717 721 737 749
..........................
The 26828th Blum integer is: 524273
</pre>
</pre>