Abundant, deficient and perfect number classifications: Difference between revisions

Content added Content deleted
(→‎{{header|REXX}}: added the REXX language. -- ~~~~)
m (→‎{{header|REXX}}: simplified some variable names.)
Line 531: Line 531:
high=word(high low 20000,1); low=word(low 1,1) /*get the LOW and HIGH. */
high=word(high low 20000,1); low=word(low 1,1) /*get the LOW and HIGH. */
say center('integers from ' low " to " high, 45, "═")
say center('integers from ' low " to " high, 45, "═")
!.=0 /*set all types of sums to zero. */
a=0; d=0; p=0 /*set all types of sums to bupkis*/
do j=low to high; $=sigma(j) /*find the sigma for an int range*/
if $<j then !.d=!.d+1 /*it's a deficient number*/
else if $>j then !.a=!.a+1 /* " " abundant " */
else !.p=!.p+1 /* " " perfect " */
end /*j*/


do j=low to high; $=sigma(j) /*find the sigma for an int range*/
say ' the number of perfect numbers: ' right(!.p, length(high))
if $<j then d=d+1 /*it's a deficient number. */
say ' the number of abundant numbers: ' right(!.a, length(high))
else if $>j then a=a+1 /* " " abundant " */
say ' the number of deficient numbers: ' right(!.d, length(high))
else p=p+1 /* " " perfect " */
end /*j*/

say ' the number of perfect numbers: ' right(p, length(high))
say ' the number of abundant numbers: ' right(a, length(high))
say ' the number of deficient numbers: ' right(d, length(high))
exit /*stick a fork in it, we're done.*/
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────SIGMA subroutine────────────────────*/
/*──────────────────────────────────SIGMA subroutine────────────────────*/