Jump to content

Numbers whose count of divisors is prime: Difference between revisions

m
→‎{{header|REXX}}: added commas to the output.
m (→‎{{header|REXX}}: changed a comment.)
m (→‎{{header|REXX}}: added commas to the output.)
Line 13:
call genP /*build array of semaphores for primes.*/
w= 10 /*W: the maximum width of any column. */
title= ' positive integers N whose number of divisors is prime, where N < ' commas(hi)
say ' index │'center(title, 1 + cols*(w+1) )
say '───────┼'center("" , 1 + cols*(w+1), '─')
Line 24:
end
finds= finds + 1 /*bump the number of found numbers. */
$= $ right( commas(j), w) /*add a positive integer ──► $ list. */
if finds//cols\==0 then iterate /*have we populated a line of output? */
say center(idx, 7)'│' substr($, 2); $= /*display what we have so far (cols). */
Line 33:
say '───────┴'center("" , 1 + cols*(w+1), '─')
say
say 'Found ' commas(finds) title
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
commas: parse arg ?; do jc=length(?)-3 to 1 by -3; ?=insert(',', ?, jc); end; return ?
/*──────────────────────────────────────────────────────────────────────────────────────*/
nDivs: procedure; parse arg x; d= 2; if x==1 then return 1 /*handle special case of 1*/
Line 58 ⟶ 60:
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
index │ positive integers N whose number of divisors is prime, where N < 10001,000
───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ 4 9 16 25 49 64 81 121 169 289
Line 64 ⟶ 66:
───────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────
 
Found 16 positive integers N whose number of divisors is prime, where N < 10001,000
</pre>
 
Cookies help us deliver our services. By using our services, you agree to our use of cookies.