Proper divisors: Difference between revisions

Content deleted Content added
Thundergnat (talk | contribs)
m →‎{{header|Perl 6}}: Further optimization
m →‎version 2: moved some statements.
Line 3,654: Line 3,654:
say right(n, max(20, w) ) 'has' center(#, 4) "proper divisors: " q
say right(n, max(20, w) ) 'has' center(#, 4) "proper divisors: " q
end /*n*/
end /*n*/
say /* [↑] process 1st range of integers.*/
m=0 /*M ≡ maximum number of Pdivs (so far).*/
m=0 /*M ≡ maximum number of Pdivs (so far).*/
do r=1 for range /*process the second range specified. */
do r=1 for range; q= Pdivs(r) /*process the second range specified. */
q= Pdivs(r); #= words(q) /*get proper divs; get number of Pdivs.*/
#= words(q); if #<m then iterate /*get proper divs; get number of Pdivs.*/
if #<m then iterate /*Less then max? Then ignore this #. */
if #<m then iterate /*Less then max? Then ignore this #. */
@.#= @.# @. r; m=# /*add this Pdiv to max list; set new M.*/
@.#= @.# @. r; m=# /*add this Pdiv to max list; set new M.*/
end /*r*/ /* [↑] process 2nd range of integers.*/
end /*r*/ /* [↑] process 2nd range of integers.*/
say

say m ' is the highest number of proper divisors in range 1──►'range,
say m ' is the highest number of proper divisors in range 1──►'range,
", and it's for: " subword(@.m, 3)
", and it's for: " subword(@.m, 3)