Jump to content

Sequence: smallest number with exactly n divisors: Difference between revisions

→‎{{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 1+(i\==1) /*now, search for a number that ≡ #divs*/
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. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
Cookies help us deliver our services. By using our services, you agree to our use of cookies.