Let n be a positive integer which representation in base 10 is $a_ka_{k-1}a_{k-2}...a_2a_1a_0$. It's not particularly hard to prove that:
$n\equiv a_0\pmod2$
$n\equiv2a_1+a_0 \pmod 4$
$n\equiv 4a_2+2a_1+a_0\pmod8$
However this doesnt seem to hold for $\pmod{16}$, what I mean is:
$n\equiv 8a_3+4a_2+2a_1+a_0\pmod{16}$
For example if we take $n = 54217$
$54217\pmod{16} = 9\;\;$ and $8*4+4*2+2*1+7 \pmod{16} = 1$
Is there anything I can add to this rule to actually make the rule work for $2^m$?