In modular arithmetic, we work with just integers and the operations used are addition, subtraction, multiplication and division. The difference between Euclidean (regular) and Gaussian (modulo) arithmetic is, Euclidean operates on infinite set of integers where as Gaussian works only with finite set of integers.
In Modular arithmetic, instead of continuing in a long, straight line, numbers go round in a circle and wrap around a certain value. This value is called the modulus. Modulus can also be defined as the length of a circular number line in modular arithmetic.
The best way to describe Modular Math is by using a clock.
The 12-hour clock operates on an infinite set of integers, that is, 1 to 12. These numbers go round in a circle and wrap around 12. This 12 is the modulus. After 12 o’ clock, it starts over at 1 again, so when it is 13 o’ clock, it is actually 1 o’ clock.
13≅1 mod 12
(When you divide 13 by 12, the remainder is 1)
This is read as,
13 is congruent to 1 mod (or modulo) 12
(When you divide 40 by 12, the remainder is 2)
This is read as,
40 is congruent to 2 mod (or modulo) 12
The “modulo operation” finds the remainder after division of one number by another (sometimes called modulus).
Modulo operator (abbreviated as mod) is the remainder after dividing a positive number by another positive number. When we divide two positive numbers, the equation will look like this:
`A/B = X` `text(remainder)` ` Y`
A is the dividend
B is the divisor
X is the quotient
Y is the remainder
`9/2 = 4` `text(remainder)` `1`
`9` mod `2` = `1` because `9` divided by `2` leaves a quotient of `4` and a remainder of `1`
`6/3 = 2` `text(remainder)` `0`
`6` mod `3 = 0 ` because `6` divided by `3` leaves a quotient of `2` and a remainder of `0`