How can I simplify $(n\,\mathrm{ mod }\,b^{k+1})\,\mathrm{ mod }\, b^k$? I am trying to simplify an expression I've found that is related to converting from a number base to another:
$$n\,\mathrm{ mod }\,b^{k+1} - (n\,\mathrm{ mod }\,b^{k+1})\,\mathrm{ mod }\, b^k$$
In this sense I mainly want to simplify the second term. I know, for instance, about the identity
$$(a\,\mathrm{ mod }\,b)\,\mathrm{ mod }\,b = a\,\mathrm{ mod }\,b$$
But I don't know if it could actually help.
 A: $n \text{ mod } b^{k+1} = r$
means $n = q b^{k+1} + r = (qb)b^k+r$ that is
$n \text{ mod } b^k = r \text{ mod } b^k$
Thus  $(n\,\mathrm{ mod }\,b^{k+1})\,\mathrm{ mod }\, b^k = n\text{ mod } b^k$
A: Alright... I have a usually rant about how $\mod m$ doesn't actually mean the remainder function and... well, I get tired of ranting.
I'm going to write what you mean by $a\mod b$ as $a \% b$ because .... reasons....
Anyway:

Claim:  If $b|c$ then $(a\% c)  \% b = a\% b$.


Proof:  Let $a\% c = r$.  Let $r\%b = s$.  Now $b|c$ so let $c = kb$.


Then $a = mc + r$ for some $m$ and $r = nb + s$ for some $n$.  ANd so $a=mc + r = (mk)b+(nb+s)=(mk+n)b + s$.


So $a\%b = s = (a\%c)\%b$.

Now to your issue at hand:
What is $n \%b^{k+1}- (n\% b^{k+1})\%b^{k}$?
Okay $n$ is and integer and suppose  $n = A\times b^k + R$ where $0\le R < b^k$.  And suppose $A = M\times b + s$ where $0 \le s < b$, then
$n = M\times b^{k+1} + s \times b^k + R$.
So $n \%b^{k+1} = s\times b^k + R$.
And $n \%b^k = R$.  So
$n \%b^{k+1}- (n\% b^{k+1})\%b^{k}=( s\times b^k + R) =s\times b^k$.
Which I think is what you where expecting.  $s$ is the $k$th place digit and we have the $k$th place digit times $b^k$.
Is there a formula for finding the $k$th digit?  Well, what we just did.  Or we could make up any notation we want.

$n\% b^{k+1} - (n\%b^{k+1})\% b^{k} = n\%b^{k+1} - n\%b^{k} = (\text{the kth digit of } n)\times b^k$.

