Perfect totient numbers

use Prime::Factor;

my \๐œ‘ = lazy 0, |(1..*).hyper.map: -> \t { t * [*] t.&prime-factors.squish.map: 1 - 1/* }
my \๐œ‘๐œ‘ = Nil, |(3, *+2 โ€ฆ *).grep: -> \p { p == sum ๐œ‘[p], { ๐œ‘[$_] } โ€ฆ 1 };

put "The first twenty Perfect totient numbers:\n",  ๐œ‘๐œ‘[1..20];

Output:

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

Last updated

Was this helpful?