Generate and show here, the first twenty Perfect totient numbers.



Related task

   Totient function


Also see

   the OEIS entry for   perfect totient numbers.
   mrob   list of the first 54


iterated_totient := proc(n::posint, total)
 if NumberTheory:-Totient(n) = 1 then
   return total + 1;
 else
   return iterated_totient(NumberTheory:-Totient(n), total + NumberTheory:-Totient(n));
 end if;
end proc:
 
isPerfect := n -> evalb(iterated_totient(n, 0) = n):
 
count := 0:
num_list := []:
for i while count < 20 do
 if isPerfectTotient(i) then
  num_list := [op(num_list), i];
  count := count + 1;
 end if;
end do;
num_list;