Abundant, deficient and perfect number classifications: Difference between revisions
Content deleted Content added
→{{header|REXX}}: added the REXX language. -- ~~~~ |
m →{{header|REXX}}: simplified some variable names. |
||
Line 531:
high=word(high low 20000,1); low=word(low 1,1) /*get the LOW and HIGH. */
say center('integers from ' low " to " high, 45, "═")
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*/▼
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))▼
▲ end /*j*/
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────SIGMA subroutine────────────────────*/
|