Perfect power detection

Write codeMedium25 min

Your task

Given an integer n (1 <= n <= 10^15), determine whether it is a perfect power, i.e. whether there exist integers b >= 2 and e >= 2 with b**e == n. If so, return the pair [b, e] using the SMALLEST possible base b (equivalently the largest exponent). If n is not a perfect power, return an empty list. For example 64 = 2^6 = 4^3 = 8^2, and the smallest base is 2, so return [2, 6].

Examples

perfect_power_check(n: int) -> list[int]
Example 1
Inputperfect_power_check(64)
Output[2, 6]