Anonymous user
Numbers whose count of divisors is prime: Difference between revisions
Numbers whose count of divisors is prime (view source)
Revision as of 04:06, 11 July 2021
, 2 years ago→{{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 < '
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)
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 '
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= when using the default inputs:}}
<pre>
index │
───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────
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 <
</pre>
|