Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Have you ever wondered how to calculate the day of the week for any given date? Or how to encrypt and decrypt messages using secret codes? Or how to create beautiful patterns and designs using numbers and shapes?
If so, then you might be interested in learning about modular arithmetic, a system of arithmetic that deals with the remainder of division.
In this blog, I will explain what modular arithmetic is, how it works, and why it is useful for many applications and purposes.
What is modular arithmetic?
Modular arithmetic is a system of arithmetic for integers, which considers the remainder. In modular arithmetic, numbers “wrap around” upon reaching a given fixed quantity (this given quantity is known as the modulus) to leave a remainder.
For example, when you divide 7 by 3, you get a quotient of 2 and a remainder of 1. In modular arithmetic, we write this as 7 mod 3 = 1, which means that 7 leaves a remainder of 1 when divided by 3.
Modular arithmetic is sometimes referred to as modulus arithmetic or clock arithmetic, because it is similar to how we measure time using a clock. For example, if it is 9 o’clock now, then 4 hours later it will be 1 o’clock, not 13 o’clock. This is because we use a 12-hour clock, which has a modulus of 12. In other words, we add or subtract multiples of 12 to get a number between 0 and 11. This is equivalent to finding the remainder when dividing by 12.
How does modular arithmetic work?
Modular arithmetic has some basic properties that are similar to normal arithmetic, such as:
These properties mean that we can perform addition, subtraction, and multiplication in modular arithmetic by first finding the remainder of each operand when divided by the modulus, then performing the operation on the remainders, and then finding the remainder of the result when divided by the modulus again.
For example, if we want to calculate (15 + 17) mod 7, we can do it as follows:
Therefore, (15 + 17) mod 7 = 4.
However, modular arithmetic also has some differences from normal arithmetic, such as:
These differences mean that we have to be careful when performing division, exponentiation, and solving equations in modular arithmetic. We may need to use some special techniques or tools to find the correct answers.
Why is modular arithmetic useful?
Modular arithmetic is useful for many applications and purposes. One of them is cryptography. Modular arithmetic is used to create and break secret codes and ciphers that are used to encrypt and decrypt messages. For example, one of the most famous ciphers in history is the Caesar cipher, which shifts each letter in a message by a fixed number of positions in the alphabet. This cipher can be seen as a form of modular arithmetic with modulus