mod Distributive Law, factoring $\!\!\bmod\!\!:$ $\ ab\bmod ac = a(b\bmod c)$

The "logic" is that we can use a mod distributive law to pull out a common factor $\,c=5,\,$ i.e.

$$ ca\bmod cn =\, c(a\bmod n)\quad\qquad $$

This decreases the modulus from $\,cn\,$ to $\,n, \,$ simplifying modular arithmetic. Also it may eliminate CRT = Chinese Remainder Theorem calculations, eliminating needless inverse computations, which are much more difficult than above for large numbers (or polynomials, e.g. see this answer).

This distributive law is often more convenient in congruence form, e.g.

$$\quad \qquad ca\equiv c(a\bmod n)\ \ \ {\rm if}\ \ \ \color{#d0f}{cn\equiv 0}\ \pmod{\! m}$$

because we have: $\,\ c(a\bmod n) \equiv c(a\! +\! kn)\equiv ca+k(\color{#d0f}{cn})\equiv ca\pmod{\!m}$

e.g. in the OP: $\ \ I\ge 1\,\Rightarrow\, 10^{\large I+N}\!\equiv 10^{\large I}(10^{\large N}\!\bmod 7)\ \ \ {\rm by}\ \ \ 10^I 7\equiv 0\,\pmod{35}$

Let's use that. First note that exponents on $10$ can be reduced mod $\,6\,$ by little Fermat,

i.e. notice that $\ \color{#c00}{{\rm mod}\,\ 7}\!:\,\ 10^{\large 6}\equiv\, 1\,\Rightarrow\, \color{#c00}{10^{\large 6J}\equiv 1}.\ $ Thus if $\ I \ge 1\ $ then as above

$\phantom{{\rm mod}\,\ 35\!:\,\ }\color{#0a0}{10^{\large I+6J}}\!\equiv 10^{\large I} 10^{\large 6J}\!\equiv 10^{\large I}(\color{#c00}{10^{\large 6J}\!\bmod 7})\equiv \color{#0a0}{10^{\large I}}\,\pmod{\!35} $

Our power $\ 5^{\large 102} = 1\!+\!6J\ $ by $\ {\rm mod}\,\ 6\!:\,\ 5^{\large 102}\!\equiv (-1)^{\large 102}\!\equiv 1$

Therefore $\ 10^{\large 5^{\large 102}}\!\! = \color{#0a0}{10^{\large 1+6J}}\!\equiv \color{#0a0}{10^{\large 1}} \pmod{\!35}\ $


Remark $\ $ For many more worked examples see the complete list of linked questions. Often this distributive law isn't invoked by name. Rather its trivial proof is repeated inline, e.g. from a recent answer, using $\,cn = 14^2\cdot\color{#c00}{25}\equiv 0\pmod{100}$

$\begin{align}&\color{#c00}{{\rm mod}\ \ 25}\!:\ \ \ 14\equiv 8^{\large 2}\Rightarrow\, 14^{\large 10}\equiv \overbrace{8^{\large 20}\equiv 1}^{\rm\large Euler\ \phi}\,\Rightarrow\, \color{#0a0}{14^{\large 10N}}\equiv\color{#c00}{\bf 1}\\[1em] &{\rm mod}\ 100\!:\,\ 14^{\large 2+10N}\equiv 14^{\large 2}\, \color{#0a0}{14^{\large 10N}}\! \equiv 14^{\large 2}\!\! \underbrace{(\color{#c00}{{\bf 1} + 25k})}_{\large\color{#0a0}{14^{\Large 10N}}\!\bmod{\color{#c00}{25}}}\!\!\! \equiv 14^{\large 2} \equiv\, 96\end{align}$

This distributive law is actually equivalent to CRT as we sketch below, with $\,m,n\,$ coprime

$\begin{align} x&\equiv a\!\!\!\pmod{\! m}\\ \color{#c00}x&\equiv\color{#c00} b\!\!\!\pmod{\! n}\end{align}$ $\,\Rightarrow\, x\!-\!a\bmod mn\, =\, m\left[\dfrac{\color{#c00}x-a}m\bmod n\right] = m\left[\dfrac{\color{#c00}b-a}m\bmod n\right]$

which is exactly the same form solution given by Easy CRT. But the operational form of this law often makes it much more convenient to apply in computations versus the classical CRT formula.

Fractional extension $ $ It easily extends to fractions, e.g. from here

Notice $\,\ \dfrac{\color{#c00}{11}}{35}\bmod \color{#c00}{11}(9)\,=\, \color{#c00}{11}(\color{#0a0}8)\,$ by $\color{#0a0}{\bmod 9\!:\ \dfrac{1}{35}\equiv \dfrac{1}{-1}\equiv 8},\ $ via

Theorem $\ \ \dfrac{\color{#c00}ab}d\bmod \color{#c00}ac\, =\, \color{#c00}a\left(\color{#0a0}{\dfrac{b}d\bmod c}\right)\ \ $ if $\ \ (d,ac) = 1$

Proof $\, $ Bezout $\Rightarrow$ exists $\, d' \equiv d^{-1}\pmod{\!ac}.\,$ Factoring out $\,\color{#c00}a\,$ by mDL

$$\color{#c00}abd'\bmod \color{#c00}ac\, =\ \color{#c00}a(bd'\bmod c)\qquad\qquad\qquad$$

and $\,dd' \equiv 1\pmod{\!ac}\Rightarrow dd' \equiv 1\pmod{\!c},\,$ so $\,d'\bmod c = d^{-1}\bmod c$


First, note that $10^{7}\equiv10^{1}\pmod{35}$.

Therefore $n>6\implies10^{n}\equiv10^{n-6}\pmod{35}$.

Let's calculate $5^{102}\bmod6$ using Euler's theorem:

  • $\gcd(5,6)=1$
  • Therefore $5^{\phi(6)}\equiv1\pmod{6}$
  • $\phi(6)=\phi(2\cdot3)=(2-1)\cdot(3-1)=2$
  • Therefore $\color\red{5^{2}}\equiv\color\red{1}\pmod{6}$
  • Therefore $5^{102}\equiv5^{2\cdot51}\equiv(\color\red{5^{2}})^{51}\equiv\color\red{1}^{51}\equiv1\pmod{6}$

Therefore $10^{5^{102}}\equiv10^{5^{102}-6}\equiv10^{5^{102}-12}\equiv10^{5^{102}-18}\equiv\ldots\equiv10^{1}\equiv10\pmod{35}$.