Perfect totient numbers: Difference between revisions
Content deleted Content added
m →{{header|REXX}}: optimized the PHI function. |
m →{{header|REXX}}: optimized the main DO loop (twice as fast). |
||
Line 122:
@.=. /*memoization array of totient numbers.*/
$= /*list of the perfect totient numbers. */
do j=3 by 2 until p==N;
a= s /* [↓] search for a perfect totient #.*/
do until a==1; a= phi(a); s= s + a
end /*until*/
if s\==j then iterate /*Is J not a perfect totient number? */
p= p + 1 /*bump count of perfect totient numbers*/
|