galois.is_perfect_power(n: int) bool

Determines if $$n$$ is a perfect power $$n = c^e$$ with $$e > 1$$.

Parameters:
n: int

An integer.

Returns:

True if the integer $$n$$ is a perfect power.

Examples

Primes are not perfect powers because their exponent is 1.

In : galois.perfect_power(13)
Out: (13, 1)

In : galois.is_perfect_power(13)
Out: False


Products of primes are not perfect powers.

In : galois.perfect_power(5*7)
Out: (35, 1)

In : galois.is_perfect_power(5*7)
Out: False


Products of prime powers where the GCD of the exponents is 1 are not perfect powers.

In : galois.perfect_power(2 * 3 * 5**3)
Out: (750, 1)

In : galois.is_perfect_power(2 * 3 * 5**3)
Out: False


Products of prime powers where the GCD of the exponents is greater than 1 are perfect powers.

In : galois.perfect_power(2**2 * 3**2 * 5**4)
Out: (150, 2)

In : galois.is_perfect_power(2**2 * 3**2 * 5**4)
Out: True


Negative integers can be perfect powers if they can be factored with an odd exponent.

In : galois.perfect_power(-64)
Out: (-4, 3)

In : galois.is_perfect_power(-64)
Out: True


Negative integers that are only factored with an even exponent are not perfect powers.

In : galois.perfect_power(-100)
Out: (-100, 1)

In : galois.is_perfect_power(-100)
Out: False