Perfect numbers: Difference between revisions
Content added Content deleted
(→{{header|REXX}}: made a version conform more to the original program. -- ~~~~) |
(→traditional method: added comments regarding the use of some shortcuts. -- ~~~~) |
||
Line 1,276: | Line 1,276: | ||
===traditional method=== |
===traditional method=== |
||
Programming note: this traditional method takes advantage of a few shortcuts: |
|||
:::* testing only goes up to the (integer) square root of '''X''' |
|||
:::* testing bypasses the test of the first and last factors |
|||
:::* a ''corresponding factor'' is used when a factor is found |
|||
:::* testing is stopped if the sum of the factors exceeds '''X''' |
|||
<lang rexx>/*REXX program tests if a number (or a range of numbers) is/are perfect.*/ |
<lang rexx>/*REXX program tests if a number (or a range of numbers) is/are perfect.*/ |
||
parse arg low high . /*obtain the specified number(s).*/ |
parse arg low high . /*obtain the specified number(s).*/ |