# Replacing powers with ReplaceRepeated

I have question about ReplaceRepeated. Consider

$$\qquad\mathsf{FullSimplify}\left[\left\{\frac{q^5-q^4}{q^5-2 q^4+2 q^2-q}\right\}\text{//.}\, \left\{q^3\to 1\right\}\right]$$

Evaluating the above expression gives

$$\qquad\left\{\frac{q^3}{(q-1)^2 (q+1)}\right\}$$

but the answer I want is 1/3.

How do I the answer in the form I want?

Simplify[(q^5-q^4)/(q^5-2q^4+2q^2-q)/.q^n_ -> q^Mod[n,3]]

• Also, (q^5 - q^4)/(q^5 - 2 q^4 + 2 q^2 - q) /. (q^n_ /; n > 2) -> q^(n - 3) // Simplify – Bob Hanlon Jan 9 '19 at 4:27