0

Is there a way to calculate $a \operatorname{mod} cd$, without actually calculating $cd$, where $c$ and $d$ are primes, and $cd$ has $12$ digits?

Vedran Šego
  • 11,372

1 Answers1

1

Yes.

If we denote $a \equiv a_c \pmod c$ and $a \equiv a_d \pmod d$, we compute $c^{-1} \pmod d$ and $d^{-1} \pmod c$ using perhaps the Extended Euclidean Algorithm, then

$$a \equiv a_c d^{-1} d + a_d c^{-1} c \pmod {cd},$$

where by $c^{-1}$ and $d^{-1}$, I mean the integers calculated above by a slight abuse of notation. This is what would come from a constructive proof of the Chinese Remainder Theorem (as is highlighted in a blog post I wrote for my students, self-plug disclaimer).