Perfect power (source code)

= Perfect power
{title2=$n=m^k,\quad k>1$}
{wiki}

An <integer> is a <perfect power> if it can be written $m^k$ with <integers> $m$ and $k>1$. In the common nontrivial positive version, both the value and the base exceed one. For example, $64=8^2=4^3=2^6$ qualifies, whereas twelve does not. The degenerate values $0$, $1$ and $-1$ are included or excluded according to the convention being used.

For a <positive integer> $n>1$ with <prime factorization> $n=\prod_i p_i^{e_i}$, the exact criterion is
$$
n\text{ is a perfect power}\quad\Longleftrightarrow\quad\gcd(e_1,\ldots,e_r)>1.
$$
If $n=m^k$, every <prime exponent> is divisible by $k$. Conversely, a common <divisor> $k>1$ lets one take $m=\prod_i p_i^{e_i/k}$. This gives a recognition test once the <prime factorization> is known; it does not imply that factorization is the fastest recognition algorithm.

A negative value requires an odd <exponent>. Thus $-64=(-4)^3$ is a <perfect power>, while $-16$ is not: its absolute value has only powers of two as common divisors of its exponents. <Perfect cubes> are the special case $k=3$, whereas a <cube-full number> imposes a different lower bound on each <prime exponent>.