Perfect numbers: Difference between revisions
Content added Content deleted
m (added whitespace before the TOC (table of contents), added a ;See also: (bold) header, used a larger font for showing the formulae.) |
m (→Classic REXX version of ooRexx: added whitespace.) |
||
Line 1,681: | Line 1,681: | ||
This version is a Classic Rexx version of the ooRexx program as of 14-Sep-2013. |
This version is a Classic Rexx version of the ooRexx program as of 14-Sep-2013. |
||
<lang rexx>/*REXX version of the ooRexx program (the code was modified to run with Classic REXX).*/ |
<lang rexx>/*REXX version of the ooRexx program (the code was modified to run with Classic REXX).*/ |
||
do i=1 to 10000 /*statement changed: LOOP ──► DO*/ |
do i=1 to 10000 /*statement changed: LOOP ──► DO*/ |
||
if perfectNumber(i) then say i "is a perfect number" |
if perfectNumber(i) then say i "is a perfect number" |
||
end |
end |
||
exit |
exit |
||
perfectNumber: procedure; parse arg n /*statements changed: ROUTINE,USE*/ |
perfectNumber: procedure; parse arg n /*statements changed: ROUTINE,USE*/ |
||
sum=0 |
sum=0 |
||
do i=1 to n%2 /*statement changed: LOOP ──► DO*/ |
do i=1 to n%2 /*statement changed: LOOP ──► DO*/ |
||
if n//i==0 then sum=sum+i /*statement changed: sum += i */ |
if n//i==0 then sum=sum+i /*statement changed: sum += i */ |
||
end |
end |
||
return sum=n</lang> |
return sum=n</lang> |