Perfect totient numbers: Difference between revisions

Content added Content deleted
(add Miranda)
(Added XPL0 example.)
Line 2,810: Line 2,810:
[3, 9, 15, 27, 39, 81, 111, 183, 243, 255, 327, 363, 471, 729, 2187, 2199, 3063, 4359, 4375, 5571]
[3, 9, 15, 27, 39, 81, 111, 183, 243, 255, 327, 363, 471, 729, 2187, 2199, 3063, 4359, 4375, 5571]
</pre>
</pre>

=={{header|XPL0}}==
{{trans|Wren}}
<syntaxhighlight lang "XPL0">func Totient(N);
int N, Tot, I;
[Tot:= N; I:= 2;
while I*I <= N do
[if rem(N/I) = 0 then
[while rem(N/I) = 0 do N:= N/I;
Tot:= Tot - Tot/I;
];
if I = 2 then I:= 1;
I:= I+2;
];
if N > 1 then Tot:= Tot - Tot/N;
return Tot;
];

proc ShowPerfect;
int N, Count, Tot, Sum;
[N:= 1; Count:= 0;
while Count < 20 do
[Tot:= N; Sum:= 0;
while Tot # 1 do
[Tot:= Totient(Tot);
Sum:= Sum + Tot;
];
if Sum = N then
[IntOut(0, N); ChOut(0, ^ );
Count:= Count+1;
];
N:= N+2;
];
];

[Text(0, "The first 20 perfect totient numbers are:^m^j");
ShowPerfect;
]</syntaxhighlight>
{{out}}
<pre>
The first 20 perfect totient numbers are:
3 9 15 27 39 81 111 183 243 255 327 363 471 729 2187 2199 3063 4359 4375 5571 </pre>


=={{header|zkl}}==
=={{header|zkl}}==