Function slow_primes::as_perfect_power [-] [+] [src]

pub fn as_perfect_power(x: u64) -> (u64, u8)

Returns integers (y, k) such that x = y^k with k maximised (other than for x = 0, 1, in which case y = x, k = 1).

Examples

assert_eq!(slow_primes::as_perfect_power(2), (2, 1));
assert_eq!(slow_primes::as_perfect_power(4), (2, 2));
assert_eq!(slow_primes::as_perfect_power(8), (2, 3));
assert_eq!(slow_primes::as_perfect_power(1024), (2, 10));

assert_eq!(slow_primes::as_perfect_power(1000), (10, 3));

assert_eq!(slow_primes::as_perfect_power(15), (15, 1));