Anonymous user
Sequence: smallest number with exactly n divisors: Difference between revisions
Sequence: smallest number with exactly n divisors (view source)
Revision as of 17:18, 11 April 2019
, 5 years ago→{{header|REXX}}: added optimization (but not really needed for only finding 15 numbers).
(→{{header|REXX}}: flushed out the REXX stub.) |
(→{{header|REXX}}: added optimization (but not really needed for only finding 15 numbers).) |
||
Line 95:
if N=='' | N=="," then N= 15 /*Not specified? Then use the default.*/
say '──divisors── ──smallest number with N divisors──' /*display title for the numbers.*/
@.= /*the @ array is used for memoization*/
do i=1 for N /*step through a number of divisors. */
do j=1+(i\==1) by
if @.j==. then iterate /*has this number already been found? */
d= #divs(j); if d\==i then iterate /*get # divisors; Is not equal? Skip.*/
say center(i, 12) right(j, 19) /*display the #divs and the smallest #.*/
@.j=. /*mark as having found #divs for this J*/
leave /*found a number, so now get the next I*/
end /*j*/
end /*i*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
|