Numbers whose count of divisors is prime: Difference between revisions

Added solution for Action!
(added AWK)
(Added solution for Action!)
Line 7:
Stretch goal:   (as above),   but where   '''n   <   100,000'''.
<br><br>
 
=={{header|Action!}}==
{{libheader|Action! Sieve of Eratosthenes}}
<lang Action!>INCLUDE "H6:SIEVE.ACT"
 
INT FUNC CountDivisors(INT x)
INT i,max,count
 
count=2 i=2 max=x
WHILE i<max
DO
IF x MOD i=0 THEN
max=x/i
IF i<max THEN
count==+2
ELSEIF i=max THEN
count==+1
FI
FI
i==+1
OD
RETURN (count)
 
PROC Main()
DEFINE MAXNUM="999"
BYTE ARRAY primes(MAXNUM+1)
 
INT i,count
 
Put(125) PutE() ;clear the screen
Sieve(primes,MAXNUM+1)
FOR i=2 TO MAXNUM
DO
IF primes(i)=0 THEN
count=CountDivisors(i)
IF count>2 AND primes(count)=1 THEN
PrintF("%I has %I divisors%E",i,count)
FI
FI
OD
RETURN</lang>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Numbers_whose_count_of_divisors_is_prime.png Screenshot from Atari 8-bit computer]
<pre>
4 has 3 divisors
9 has 3 divisors
16 has 5 divisors
25 has 3 divisors
49 has 3 divisors
64 has 7 divisors
81 has 5 divisors
121 has 3 divisors
169 has 3 divisors
289 has 3 divisors
361 has 3 divisors
529 has 3 divisors
625 has 5 divisors
729 has 7 divisors
841 has 3 divisors
961 has 3 divisors
</pre>
 
=={{header|ALGOL 68}}==
Line 48 ⟶ 109:
73441 76729 78961 80089 83521 85849 94249 96721 97969
</pre>
 
=={{header|AWK}}==
<lang AWK>
Anonymous user