RosettaCodeData/Task/Perfect-totient-numbers/Factor/perfect-totient-numbers.factor
2023-07-01 13:44:08 -04:00

9 lines
239 B
Factor

USING: formatting kernel lists lists.lazy math
math.primes.factors ;
: perfect? ( n -- ? )
[ 0 ] dip dup [ dup 2 < ] [ totient tuck [ + ] 2dip ] until
drop = ;
20 1 lfrom [ perfect? ] lfilter ltake list>array
"%[%d, %]\n" printf