Anonymous user
Anti-primes: Difference between revisions
→version 1: changed the format of the output from horizontal to vertical.
(Promote to full task status.) |
(→version 1: changed the format of the output from horizontal to vertical.) |
||
Line 353:
if N=='' | N=="," then N=20 /*Not specified? Then use the default.*/
maxD= 0 /*the maximum number of divisors so far*/
say '─index─ ──anti─prime──' /*display a title for the numbers shown*/
#= 0 /*the count of anti─primes found " " */
do once=1 for 1
$= /*the list of anti─primes found " " */▼
do
d= #divs(i); if d<=maxD then iterate /*get # divisors;
#= # + 1; maxD= d
end /*i*/
do j=60 by 20 /*step through possible numbers by 20. */
d= #divs(j); if d<=maxD then iterate /*get # divisors; Is too small? Skip.*/
#= # + 1; maxD= d /*found an anti─prime #; set new minD.*/
say center(#, 7) right(j, 10) /*display the index and the anti─prime.*/
if #>=N then leave once /*if we have enough anti─primes, done. */
end /*j*/
end /*once*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
#divs: procedure; parse arg x 1 y /*X and Y: both set from 1st argument.*/
if x<3 then return x /*handle special
if x==4 then return 3 /* " " " " four. */
if x<6 then return 2 /* " " " " three or five*/
Line 383 ⟶ 390:
{{out|output|text= when using the default input of: <tt> 20 </tt>}}
<pre>
─index─ ──anti─prime──
2 2
3 4
4 6
5 12
6 24
7 36
8 48
9 60
10 120
11 180
12 240
13 360
14 720
15 840
16 1260
17 1680
18 2520
19 5040
20 7560
</pre>
|