galois.perfect_power

galois.perfect_power(n)

Returns the integer base \(c > 1\) and exponent \(e > 1\) of \(n = c^e\) if \(n\) is a perfect power.

Parameters

n (int) – A positive integer \(n > 1\).

Returns

None is \(n\) is not a perfect power. Otherwise, \((c, e)\) such that \(n = c^e\). \(c\) may be composite.

Return type

None, tuple

Examples

# Primes are not perfect powers
In [1]: galois.perfect_power(5)

# Products of primes are not perfect powers
In [2]: galois.perfect_power(2*3)

# Products of prime powers were the GCD of the exponents is 1 are not perfect powers
In [3]: galois.perfect_power(2 * 3 * 5**3)

# Products of prime powers were the GCD of the exponents is > 1 are perfect powers
In [4]: galois.perfect_power(2**2 * 3**2 * 5**4)
Out[4]: (150, 2)

In [5]: galois.perfect_power(36)
Out[5]: (6, 2)

In [6]: galois.perfect_power(125)
Out[6]: (5, 3)