Untouchable numbers: Difference between revisions

→‎{{header|ALGOL 68}}: Use ALGOL 68-primes
m (→‎{{header|ALGOL 68}}: Notes on how to run with Algol 68G)
(→‎{{header|ALGOL 68}}: Use ALGOL 68-primes)
Line 71:
<br><br>
Note that under Windows (and possibly under Linux), Algol 68G requires that the heap size be increased in order to allow arrays big enough to handle 100 000 and 1 000 000 untouchable numbers. See [[ALGOL_68_Genie#Using_a_Large_Heap]].
{{libheader|ALGOL 68-primes}}
<lang algol68>BEGIN # find some untouchable numbers - numbers not equal to the sum of the #
# proper divisors of any +ve integer #
Line 127 ⟶ 128:
# sieve the primes to max untouchable and flag the non untouchables #
BEGIN
PR read "primes.incl.a68" PR
[ 1 : UPB untouchable ]BOOL prime;
prime[ 1 ] := FALSE;BOOL prime[ 2= ]PRIMESIEVE :=max TRUEuntouchable;
FOR i FROM 3 BY 2 TO UPB prime DO prime[ i ] := TRUE OD;
FOR i FROM 4 BY 2 TO UPB prime DO prime[ i ] := FALSE OD;
FOR i FROM 3 BY 2 TO ENTIER sqrt( UPB prime ) DO
IF prime[ i ] THEN
FOR s FROM i * i BY i + i TO UPB prime DO prime[ s ] := FALSE OD
FI
OD;
FOR i FROM 3 BY 2 TO UPB prime DO
IF prime[ i ] THEN
3,021

edits