x = factorIntegerPower(n)
factors the number n into its perfect power xk and returns the base x. If several perfect
powers exist, x is returned for maximum k.
The function factorIntegerPower acts element-wise on array
input.
Factor 64 into its perfect power. If
several perfect powers exist for a number, the maximum k is
returned.
n = 64;
[x,k] = factorIntegerPower(n)
x =
2
k =
6
Find perfect powers of 7, 841, and
2541865828329.
n = [7 841 2541865828329];
[x,k] = factorIntegerPower(n)
x =
7 29 3
k =
1 2 26
Reconstruct the numbers. Return exact symbolic integers instead of
floating point by converting x to symbolic form.
sym(x).^k
ans =
[ 7, 841, 2541865828329]
If a number is not a perfect power,
factorIntegerPower returns the number itself as the
base with exponent 1. So, a number is a perfect power if it
does not equal its base.
Check if 125 is a perfect power.
isequal returns logical 0
(false), meaning 125 is not equal
to the returned base. Therefore, 125 is a perfect
power.