1. ## Some modular arithmetic

Hello everyone!

I'm new to modular arithmetic, I read a few identities like:
$\displaystyle (a+b)\mod N = ( (a\mod N) + (b\mod N) )\mod N$ and
$\displaystyle (a \times b)\mod N = ( (a\mod N) \times (b\mod N) ) \mod N$... I searched this, but couldn't find an identity for this:
$\displaystyle a^b\mod N = (a \times a \times \cdots \times a) \mod N = (a \mod N)^b \mod N$. But so what? We didn't reduce the equation, we just replaced $\displaystyle a$ by $\displaystyle a \mod N$.
Is there a way that calculates or defines $\displaystyle a^b \mod N$ ?

2. In this case, $\displaystyle b$ (and in general any exponent) cannot be "reduced" that easily, as $\displaystyle b$ is replaced by $\displaystyle b \mod{\varphi{(n)}}$, where $\displaystyle \varphi{(n)}$ is the Euler Totient of $\displaystyle n$.

So $\displaystyle a^b \equiv (a \mod{n})^{b \mod{\varphi{(n)}}} \pmod{n}$

The following goes beyond basic number theory - this can be shown, interestingly, to "pile up" for various exponent levels, and the $\displaystyle \varphi$ function is iterated :

$\displaystyle a^{(b^c)} \equiv (a \mod{n})^{\displaystyle (b^{c \mod{\varphi{(\varphi{(n)})}}}) \mod{\varphi{(n)}}} \pmod{n}$