Prime words: Difference between revisions
Content added Content deleted
m (→{{header|Phix}}: use unix_dict()) |
(→{{header|ALGOL 68}}: Use ALGOL 68-primes) |
||
Line 24: | Line 24: | ||
<br><br> |
<br><br> |
||
=={{header|ALGOL 68}}== |
=={{header|ALGOL 68}}== |
||
{{libheader|ALGOL 68-primes}} |
|||
Does not distinguish between letters and non-letter ASCII codes (as with the REXX sample). |
Does not distinguish between letters and non-letter ASCII codes (as with the REXX sample). |
||
<lang algol68># find words whose character codes are primes # |
<lang algol68># find words whose character codes are primes # |
||
Line 45: | Line 46: | ||
END |
END |
||
); |
); |
||
# construct a sieve of primes up to the maximum character # |
# construct a sieve of primes up to the maximum character # |
||
PR read "primes.incl.a68" PR |
|||
[ 0 : max abs char ]BOOL s; |
|||
[]BOOL s = PRIMESIEVE max abs char; |
|||
s[ 0 ] := s[ 1 ] := FALSE; |
|||
FOR i FROM 2 TO ENTIER sqrt( UPB s ) DO |
|||
IF s[ i ] THEN FOR p FROM i * i BY i TO UPB s DO s[ p ] := FALSE OD FI |
|||
OD; |
|||
# find the prime words # |
# find the prime words # |
||
INT prime count := 0; |
INT prime count := 0; |
||
Line 106: | Line 103: | ||
36: q |
36: q |
||
</pre> |
</pre> |
||
=={{header|Arturo}}== |
=={{header|Arturo}}== |
||