Untouchable numbers: Difference between revisions
Content added Content deleted
m (→{{header|ALGOL 68}}: Notes on how to run with Algol 68G) |
(→{{header|ALGOL 68}}: Use ALGOL 68-primes) |
||
Line 71: | Line 71: | ||
<br><br> |
<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]]. |
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 # |
<lang algol68>BEGIN # find some untouchable numbers - numbers not equal to the sum of the # |
||
# proper divisors of any +ve integer # |
# proper divisors of any +ve integer # |
||
Line 127: | Line 128: | ||
# sieve the primes to max untouchable and flag the non untouchables # |
# sieve the primes to max untouchable and flag the non untouchables # |
||
BEGIN |
BEGIN |
||
PR read "primes.incl.a68" PR |
|||
[ 1 : UPB untouchable ]BOOL prime; |
|||
[]BOOL prime = PRIMESIEVE max untouchable; |
|||
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 |
FOR i FROM 3 BY 2 TO UPB prime DO |
||
IF prime[ i ] THEN |
IF prime[ i ] THEN |