CalmoSoft primes: Difference between revisions
→Stretch: It's faster using Miller-Rabin...
(→{{header|ALGOL 68}}: Fixed </pre>) |
(→Stretch: It's faster using Miller-Rabin...) |
||
Line 77:
===Stretch===
Basically the same algorithm as the Algol 68 Basic task sample.
{{works with|ALGOL 68G|Any - tested with release 2.8.3.win32}}
Uses Algol 68G's LONG LONG INT for the Millar Rabin test.
<br>Took about 30 seconds with Algol 68G on the Windows 11 system I'm using, 40-45 seconds on TIO.RUN.
{{libheader|ALGOL 68-primes}}
<syntaxhighlight lang="algol68">
BEGIN # find the longest sequence of primes < 50 000 000 that sums to a prime#
# called Calmosoft primes #
PR read "primes.incl.a68" PR
INT max prime = 50 000 000;
[ 0 : max prime ]BOOL prime;
Line 128 ⟶ 120:
WHILE IF this end < this start OR this len < max len
THEN FALSE
ELSE NOT ( this prime := is probably prime( this sum ) )
FI
DO
|