Perfect totient numbers: Difference between revisions
Content deleted Content added
→{{header|zkl}}: added code |
m →{{header|REXX}}: optimized the PHI function. |
||
Line 122:
@.=. /*memoization array of totient numbers.*/
$= /*list of the perfect totient numbers. */
do j=3 until p==N; s= phi(j)
a= s /* [↓] search for a perfect totient #.*/
if s\==j then iterate /*Is J not a perfect totient number? */
p= p + 1 /*bump count of perfect totient numbers*/
Line 135:
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
gcd: parse arg x,y;
return x
/*──────────────────────────────────────────────────────────────────────────────────────*/
phi: procedure expose @.; parse arg z; if @.z\==. then return @.z
#= z==1;
@.z= #; return # /*use memoization. */</lang>
{{out|output|text= when using the default input of : <tt> 20 </tt>}}
|