Introduction
Number theory is a branch of mathematics that deals with the properties and relationships of numbers, particularly integers
. It involves the study of prime numbers, divisibility, and the structure of the set of integers. Number theory has many applications in cryptography
, computer science
, and pure mathematics
.
Modular arithmetic
Modular arithmetic is a system of arithmetic for integers where numbers "wrap around" upon reaching a certain value called the modulus. It is often described as "clock arithmetic," where after reaching a certain value, the counting starts again from zero.
For example, in modular arithmetic, if the modulus is 12 (like a clock), after 11 comes 0, then 1, 2, etc.
Mathematically, we write modular arithmetic as:
This means that when is divided by , the remainder is . In other words, and are congruent modulo . It is also often represented as symbol
Properties of modulo arithmetic
Here is multiplicative modulo inverse
of and
Example
-
Assume = , = and = and we need to find . This would easily overflow in
int
orlong
resulting in incorrect results. On applying - we would be able to solve this correctly here is how - -