Anonymous user
Abundant odd numbers: Difference between revisions
m
→{{header|REXX}}: added wording to the REXX section header, used staggered quote style, optimized the sigO function.
(→{{header|Python}}: Added a functionally composed Python draft.) |
m (→{{header|REXX}}: added wording to the REXX section header, used staggered quote style, optimized the sigO function.) |
||
Line 1,799:
=={{header|REXX}}==
A wee bit of coding was added to add commas to numbers (because of the larger numbers) as well as alignment of the output.
<lang rexx>/*REXX pgm displays abundant odd numbers: 1st 25, one─thousandth, first > 1 billion. */
parse arg Nlow Nuno Novr . /*obtain optional arguments from the CL*/
Line 1,811:
if $<=j then iterate /*sigma ≤ J ? Then ignore it. */
#= # + 1 /*bump the counter for abundant odd #'s*/
say rt(th(#)) @ 'is:'rt(commas(j), 8) rt(
end /*j*/
say
Line 1,819:
#= # + 1 /*bump the counter for abundant odd #'s*/
if #<Nuno then iterate /*Odd abundant# count<Nuno? Then skip.*/
say rt(th(#)) @ 'is:'rt(commas(j), 8) rt(
leave /*we're finished displaying NUNOth num.*/
end /*j*/
Line 1,834:
th: parse arg th; return th||word('th st nd rd',1+(th//10)*(th//100%10\==1)*(th//10<4))
/*──────────────────────────────────────────────────────────────────────────────────────*/
sigO:
do k=3 by 2 while k*k<x
if x//k==0 then s= s + k +
end /*k*/
if k*k==x then return s + k /*Was X a square? If so, add √ x */
return s /*return (sigma) sum of the divisors. */</lang>
|