1

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$?

1 Answers1

1

The actual rule for $n = a_k \ldots a_0$ mod $2^d$ is $$n \equiv a_0 + 10^1 a_1 + 10^2 a_2 + \ldots + 10^{d-1} a_{d-1} \mod 2^d$$ So for $16$ that would be $$n \equiv a_0 + 10 a_1 + 4 a_2 + 8 a_3 \mod 16$$ for $32$ it would be $$n \equiv a_0 + 10 a_1 + 4 a_2 + 8 a_3 + 16 a_4 \mod 32$$ and for $64$ it would be
$$ n \equiv a_0 + 10 a_1 + 36 a_2 + 40 a_3 + 16 a_4 + 32 a_5 \mod 64 $$

Robert Israel
  • 448,999