# Prime Numbers and Cryptography

Algorithms for finding prime numbers date back at least as far as ancient Greece, where mathematicians used a straightforward approach known as the Sieve of Erastothenes. The Sieve of Erastothenes works as follows: To find all the primes less than n, begin by writing down all the numbers from 1 to n in sequence. Then cross out all the numbers that are multiples of 2, besides itself (4, 6, 8, 10, 12, and so on). Take the next smallest number that hasn’t been crossed out (in this case, 3), and cross out all multiples of that number (6, 9, 12, 15). Keep going like this, and the numbers that remain at the end are the primes.

For millennia, the study of prime numbers was believed to be, as G. H. Hardy put it, “one of the most obviously useless branches” of mathematics. But it lurched into practicality in the twentieth century, becoming pivotal in cryptography and online security. As it happens, it is much easier to multiply primes together than to factor them back out. With big enough primes—say, a thousand digits —the multiplication can be done in a fraction of a second while the factoring could take literally millions of years; this makes for what is known as a “one-way function.” In modern encryption, for instance, secret primes known only to the sender and recipient get multiplied together to create huge composite numbers that can be transmitted publicly without fear, since factoring the product would take any eavesdropper way too long to be worth attempting. Thus virtually all secure communication online—be it commerce, banking, or email—begins with a hunt for prime numbers.

This cryptographic application suddenly made algorithms for finding and checking primes incredibly important. And while the Sieve of Erastothenes is effective, it is not efficient. If you want to check whether a particular number is prime—known as testing its “primality”—then following the sieve strategy requires trying to divide it by all the primes up to its square root.* Checking whether a six-digit number is prime would require dividing by all of the 168 primes less than 1,000—not so bad. But checking a twelve-digit number involves dividing by the 78,498 primes less than 1 million, and all that division quickly starts to get out of control. The primes used in modern cryptography are hundreds of digits long; forget about it.

## Notes:

**Folksonomies:** prime numbers cryptography computational thinking

**Taxonomies:**

/science/mathematics/arithmetic (0.975465)

/science/mathematics/geometry (0.670334)

**Concepts:**

Prime number (0.965426): dbpedia_resource

Mathematics (0.728559): dbpedia_resource

Cryptography (0.683287): dbpedia_resource

Sieve of Eratosthenes (0.672945): dbpedia_resource

1 (0.603908): dbpedia_resource

Natural number (0.597707): dbpedia_resource

Number theory (0.590562): dbpedia_resource

Sieve theory (0.536217): dbpedia_resource

**Algorithms to Live By**

**Books, Brochures, and Chapters>**

**Book:**Christian, Brian (April 19th 2016)

*, Algorithms to Live By*, Henry Holt and Co., Retrieved on 2021-09-27

**Folksonomies:**computer science algorithms optimization optimal living