Perfect numbers: Difference between revisions

Content added Content deleted
(→‎traditional method: added comments regarding the use of some shortcuts. -- ~~~~)
m (→‎optimized using digital root: added a factoid. -- ~~~~)
Line 1,316: Line 1,316:


===optimized using digital root===
===optimized using digital root===
This REXX version makes use of the fact that all known perfect numbers > 6 have a ''digital root'' of   '''1'''.
<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).*/