Quad-power prime seeds: Difference between revisions

Content added Content deleted
m (Add escape for language that can't reasonably reach task goal.)
(→‎{{header|ALGOL 68}}: Added widening so can also run under ALGOL 68G version 2)
Line 22: Line 22:


=={{header|ALGOL 68}}==
=={{header|ALGOL 68}}==
{{works with|ALGOL 68G|Any - tested with release 3.0.3 under Windopws}}
{{works with|ALGOL 68G|Any - tested with release 3.0.3 under Windows 10}}
This uses ALGOL 68G's LONG LONG INT during the Miller Rabin testing, under ALGOL 68G version three, the default precision of LONG LONG INT is 72 digits and LONG INT is 128 bit.
This uses ALGOL 68G's LONG LONG INT during the Miller Rabin testing, under ALGOL 68G version three, the default precision of LONG LONG INT is 72 digits and LONG INT is 128 bit.
A sieve is used to (hopefully) quickly eliminate non-prime 2n+1 numbers - Miller Rabin is used for n^2+n+1 etc. that are larger than the sieve.
A sieve is used to (hopefully) quickly eliminate non-prime 2n+1 numbers - Miller Rabin is used for n^2+n+1 etc. that are larger than the sieve.
Line 66: Line 66:
THEN
THEN
# n^1 + n + 1 is prime #
# n^1 + n + 1 is prime #
LONG INT np := n * n;
LONG INT np := LENG n * LENG n;
IF is prime( np + n1 ) THEN
IF is prime( np + n1 ) THEN
# n^2 + n + 1 is prime #
# n^2 + n + 1 is prime #