I wanted to know how would I use Mathematica in order to check if the number is a perfect power I saw the algorithm but couldn't grasp it enough to implement it, so can anybody help?
The function below returns the power of n.
power[n_] := GCD @@ (FactorInteger[n][[All, 2]])
If you deal with very large numbers where
FactorInteger simply can't help, you could use trial exponents
Where to stop (I mean m) depends on the length of the number.
Inspired by tchronis's answer and Leonid's comment I came up with
powers[int_] := FactorInteger[int][[All, 2]] perfectPowerQ[int_] := (GCD @@ powers[int] > 1)
powers tells you what powers the prime factors are raised to to get the required number while
perfectPowerQ checks that all these powers are the same.