# Does $\ (g^a Mod\ p)^b\,$ $\equiv$ $\ (g^a)^b (Mod\ p)\,$ hold true?

Are these two equations: $$\ (g^a Mod\ p)^b\,$$

$$\ (g^a)^b (Mod\ p)\,$$ one and the same? If yes then how And if no then how to solve the first equation?

• I assume by $x \bmod y$ you mean the remainder when $x$ is divided by $y$? (do you take the remainder in $0 \leq r < y$?) And by "solve" are you just asking how to do arithmetic, or is there more you haven't written? If it's just arithmetic, you do it the way you normally do: one operation at a time, possibly with shortcuts if you see the possibility to use them. (e.g. computing a modular exponentiation rather than computing an exponentiation followed by a remainder, because you know both ways give the same value) – Hurkyl Apr 13 '13 at 9:51
• i want to know,how do we solve this (3^5 Mod 7)^11 step by step ? and is it true that (3^5 Mod 7)^11 is equivalent to "(3^5)^11 (Mod 7)" which is "3^55 (Mod 7)" or "x^ab (Mod p)" – Varun Parikh Apr 13 '13 at 10:11
• Go quickly to the FAQ section and read how to write properly mathematics in this site using LaTeX, otherwise your question runs the risk of not being read, leave alone addressed, by many people. – DonAntonio Apr 13 '13 at 10:38
• Notice that there are no equations in your question. – Lubin Apr 13 '13 at 14:36

If $a\equiv a'\pmod n$ and $b\equiv b'\pmod n$, then $ab\equiv a'b'\pmod n\,$.