µÆE;¬g/’µ#Ṫ
在线尝试!。
背景
每一个正整数ķ可以唯一被因式分解为第一的幂的乘积米素数,即ķ= P 1 α 1 ⋯p 米α 米,其中α 米 > 0。
我们有一个b(B> 1)的一些正整数一个当且仅当b是所有指数的除数α Ĵ。
因此,一个整数K> 1是一个完美的功率,当且仅当满足gcd(α 1,⋯,α 米)≠1 。
怎么运行的
µÆE;¬g/’µ#Ṫ Main link. No arguments.
µ Make the chain monadic, setting the left argument to 0.
µ# Find the first n integers k, greater or equal to 0, for which the
preceding chain returns a truthy value.
In the absence of CLAs, n is read implicitly from STDIN.
ÆE Compute the exponents of the prime factorization of k.
;¬ Append the logical NOT of k, i.e., 0 if k > 0 and 1 otherwise.
This maps 1 -> [0] and [0] -> [1].
g/ Reduce the list of exponents by GCD.
In particular, we achieved that 1 -> 0 and 0 -> 1.
’ Decrement; subtract 1 from the GCD.
This maps 1 to 0 (falsy) and all other integers to a truthy value.
Ṫ Tail; extract the last k.