Perfect totient numbers: Difference between revisions

Add PL/I
(→‎{{header|jq}}: gojq too)
(Add PL/I)
Line 1,324:
3 9 15 27 39 81 111 183 243 255 327 363 471 729 2187 2199 3063 4359 4375 5571
</pre>
 
=={{header|PL/I}}==
<lang pli>perfectTotient: procedure options(main);
gcd: procedure(aa, bb) returns(fixed);
declare (aa, bb, a, b, c) fixed;
a = aa;
b = bb;
do while(b ^= 0);
c = a;
a = b;
b = mod(c, b);
end;
return(a);
end gcd;
totient: procedure(n) returns(fixed);
declare (i, n, s) fixed;
s = 0;
do i=1 to n-1;
if gcd(n,i) = 1 then s = s+1;
end;
return(s);
end totient;
perfect: procedure(n) returns(bit);
declare (n, x, sum) fixed;
sum = 0;
x = n;
do while(x > 1);
x = totient(x);
sum = sum + x;
end;
return(sum = n);
end perfect;
declare (n, seen) fixed;
seen = 0;
do n=3 repeat(n+2) while(seen<20);
if perfect(n) then do;
put edit(n) (F(5));
seen = seen+1;
if mod(seen,10) = 0 then put skip;
end;
end;
end perfectTotient;</lang>
{{out}}
<pre> 3 9 15 27 39 81 111 183 243 255
327 363 471 729 2187 2199 3063 4359 4375 5571</pre>
 
=={{header|PL/M}}==
2,119

edits