# Number Theoryapplication of prime numbers

#### matqkks

##### Member
Why are prime numbers important in real life? What practical use are prime numbers?

#### Bacterius

##### Well-known member
MHB Math Helper
Prime numbers have lots of applications in number-theoretical cryptography, such as RSA, Diffie-Hellman key exchange, etc.. well, many of them don't work *specifically* because of prime numbers, but they work on specific mathematical structures such as groups or fields, and prime numbers over the integers tend to have some interesting properties and are relatively well-understood (from a practical standpoint anyway - there's still much to learn about primes, but we know how to find out if an integer is prime efficiently, we understand many of their properties, so they are useful in real life too and not just in some abstract sense).

#### Deveno

##### Well-known member
MHB Math Scholar
One of the best examples comes from modular arithmetic.

In general, with any integer n, if you add two numbers and compute the remainder upon division by n, you get the same integer as when you compute the remainders upon division by n of each summand FIRST, and then add them together (again computing the remainder upon division by n, if this smaller sum is larger than n).

An example:

341 + 113 = 454

The remainder of 454 upon division by 6 is 4 (454 = 6*75 + 4)

The remainder of 341 upon division by 6 is 5 (341 = 6*56 + 5)

The remainder of 113 upon division by 6 is 5 (113 = 6*18 + 5)

5 + 5 = 10, when divided by 6, we get a remainder of 4.

This is usually written:

a (mod 6) + b (mod 6) = (a+b) (mod 6)

This works with multiplication, as well:

(a (mod 6))*(b (mod 6)) = (ab) (mod 6)

The trouble is, when we multiply and get 0 (mod 6), we can't "undo" the operation, in other words we can have:

ab = 0 (mod 6)

with neither a or b being 0 mod 6 (for example, a = 3 and b = 4).

If we work with a PRIME modulus, a wonderful thing occurs, we can divide, too! This means we can do "the algebra we're used to" with a much smaller number system, and things still work a lot like we expect them to.

The simplest such system, of course, is using the modulus p = 2 (also known as "parity arithmetic"). This gives us the familiar rules:

Odd + Even = Odd
Odd + Odd = Even
Even + Even = Even

Odd*Even = Even
Odd*Odd = Odd
Even*Even = Even

In this system, "Even" is the "zero", and multiplication is rather trivial, the only non-zero product is "Odd*Odd = Odd" (or, if you like, 1*1 = 1, only 1 has an inverse).

That is, we can treat the properties "even" and "odd" as if they were numbers, and do arithmetic with them. In other words addition and multiplication preserve "how far between two multiples of p" numbers are.

As a practical matter, calculations of very large numbers can then be checked by calculations of relatively small numbers, which I'm sure you can see is very useful.