Perfect totient numbers: Difference between revisions

Added Perl example
(Added C implementation)
(Added Perl example)
Line 203:
The output is the same as before.
 
=={{header|Perl}}==
{{libheader|ntheory}}
<lang perl>use ntheory qw(euler_phi);
 
sub phi_iter { my($p) = @_; return euler_phi($p) + ($p == 2 ? 0 : phi_iter(euler_phi($p))) }
 
$p = 1;
while () {
$p++;
push @perfect, $p if $p == phi_iter($p);
last if 20 == @perfect;
}
printf "The first twenty perfect totient numbers:\n%s\n", my $result = join ' ', @perfect;</lang>
{{out}}
<pre>The first twenty Perfect totient numbers:
3 9 15 27 39 81 111 183 243 255 327 363 471 729 2187 2199 3063 4359 4375 5571</pre>
=={{header|Perl 6}}==
{{works with|Rakudo|2018.11}}
2,392

edits