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


#include"totient.bas"
 
dim as uinteger found = 0, curr = 3, sum, toti
 
while found < 20
    sum = totient(curr)
    toti = sum
    do
        toti = totient(toti)
        sum += toti
    loop while toti <> 1  
    if sum = curr then
        print sum
        found += 1
    end if
    curr += 1
wend