What is different in calculating modulo prime and not prime number?

1.3k Views Asked by At

The basic modulo operations: $$(A + B ) \text{ mod } P = (A \text{ mod } P + B \text{ mod } P) \text{ mod } P\\(A - B ) \text{ mod } P = (A \text{ mod } P - B \text{ mod } P) \text{ mod } P\\(A * B ) \text{ mod } P = (A \text{ mod } P * B \text{ mod } P) \text{ mod } P$$

I have tried to prove that those operations are not valid when $P$ is not prime, but I cannot even start with it, since I'm begginer in proof-writing.

3

There are 3 best solutions below

0
On BEST ANSWER

All those operations are valid and well-defined for any $\;p\in\Bbb Z\;$ . What you can do with primes and not with non-primes is division. Fo example, $\;3/4\pmod 6\;$ has no meaning as $\;4\;$ is not invertible modulo $\;6\;$ , yet modulo any prime $\;\neq2,3\;$ it is, say

$$\frac34\pmod 7=3\cdot4^{-1}\pmod7=3\cdot2\pmod 7=6\pmod 7=-1\pmod 7$$

0
On

Indeed they are always true even for p not prime and this is why modular arithmetic works.

https://en.m.wikipedia.org/wiki/Modular_arithmetic

0
On

Another related difference is that the ring $\mathbf Z/n\mathbf Z$ is a field if $n$ is prime, whereas, it it's not, it has zero-divisors, i.e. from $ab=0$, you cannot conclude that $a$ or $b=0$ (for instance $2\cdot 3= 0\mod 6$). Still worse, you can have nilpotent elements: for instance, in $\mathbf Z/24\mathbf Z$: $$6\ne 0,\quad6^2=12\ne 0,\quad 6^3=0.$$ This happens if and only if $n$ is not square-free.