CalmoSoft primes: Difference between revisions
→{{header|ALGOL 68}}: fix the basic taks trial division primality test (no really :o, though the bug didn't affect the result) and stop when the next sequence can't be longer than the max
(Algol 68 Stretch - combine sieving the primes and converting the sieve into a list) |
(→{{header|ALGOL 68}}: fix the basic taks trial division primality test (no really :o, though the bug didn't affect the result) and stop when the next sequence can't be longer than the max) |
||
Line 26:
ELSE
BOOL is a prime := TRUE;
FOR f FROM 5 BY 2 WHILE f * f <= n AND
OD;
is a prime
FI # is prime # ;
Line 37 ⟶ 38:
INT max len := -1;
INT max sum := -1;
FOR this start FROM LWB prime TO UPB prime - 1
WHILE
INT this end := UPB prime;
INT this len := ( this end + 1 ) - this start;
Line 58 ⟶ 60:
FI
FI;
( UPB prime - this start ) > max len
DO
# the start prime won't be in the next sequence #
seq sum -:= prime[ this start ]
|