Prove that if a and b are integers such that a|b and b > 0, then (x mod b) mod a = x mod a for any x.
Solution: As a|b, we have b = pa for some integer p. Let x mod b = r, then we have x = bq + r = apq + r for some integer q. Hence, we have x mod a = r mod a = (x mod b) mod a
I don't see how the author of this proof went from x = bq + r = apq + r to x mod a = r mod a. Can someone please explain this to me?