Is Digit-wise calculation possible? Suppose we have to do an intense calculation, like calculating $a^b$ for large $a$ and $b$. Then, instead of multiplying $a$ by itself $b$ times, could we just do some shortcut method with $a$ and $b$ which gives us the units digit of $a^{b}$, then another algorithm which gives the tens digit and hence, could we find the answer digit-by-digit?
I mean, could we have a function $f$ or any algorithm which takes three inputs: $a$, $b$, and $n$, such that $f(a,b,n)$ gives us the $n^{th}$ digit of $a^b$?
Similarly, could we have another algorithm, which takes inputs $a$ and $n$ and gives us the $n^{th}$ digit of $a!$, i.e. calculating factorials digit-wise?
Maybe, it's like a divisibility test where you have an algorithm to check whether $a$ is divisible by $b$ without actually dividing $a$ by $b$. Maybe, binary could be of some help in digit-wise calculation, because in binary, all the digits can have only two possible values.

If $a$ is coprime to $10$, then $a^n \mod 10^k$ is periodic in $n$ with period dividing $\varphi(10^k) = 4 \times 10^{k-1}$.  Thus the lowest $k$ decimal digits of 
$a^n$ are the same as those of $a^m$ where $n \equiv m \mod 4 \times 10^{k-1}$.
For example, since $21 \equiv 1 \mod 4$, the lowest digit of $7^{21}$ is the same as that of $7^1$, namely $7$.
In the case of $7$, it turns out that the order of $7 \mod 1000$ is actually $20$, so the lowest three digits of $7^{21}$ are the same as those of $7^1$, namely $007$.
