Anti-primes: Difference between revisions
→{{header|ALGOL 68}}: Use a dynamically allocated table of divisor counts to avoid a hard-coded limit
(Added Miniscript) |
(→{{header|ALGOL 68}}: Use a dynamically allocated table of divisor counts to avoid a hard-coded limit) |
||
Line 309:
=={{header|ALGOL 68}}==
<syntaxhighlight lang="algol68">
# previous numbers #
REF[]INT
INT max divisors := 0;
INT a count := 0;▼
ndc := HEAP[ 1 : UPB ndc + 5 000 ]INT;
OD;▼
FOR i FROM 1 TO UPB ndc DO ndc[ i ] := 1 OD;
▲ # show the numbers with more divisors than their predecessors #
FOR i FROM 2 TO UPB ndc DO
▲ INT a count := 0;
FOR j FROM i BY i TO UPB ndc
IF divisor count > max divisors THEN▼
IF ndc[ n ]
a count +:= 1
FI
OD;
print( ( newline ) )
END
{{out}}
<pre>
|