Nepedia
Back to Discover
Fluent Reader
🔢

Primality test

math Maturity 11-13 Next article →

Have you ever wondered how computers keep secrets safe? They use a special kind of math called cryptography. This math relies on knowing if a number is prime. A prime number is a number that can only be divided by one and itself. A primality test is a set of steps used to find this out. These tests are very important for digital security. They help protect your data every single day.

One of the oldest ways to test a number is trial division. This works by trying to divide your number by other numbers. You check to see if there is any remainder left over. If a number divides evenly, the number is composite, or not prime. You do not have to check every single number, though. You only need to check prime numbers up to the square root of your number. For example, to test 17, you only check 2 and 3. Since neither works, 17 is prime.

Some tests are much faster than trial division but use a bit of luck. These are called probabilistic tests. They pick a random number to test against your number. These tests can sometimes be fooled by a composite number. This is called a pseudoprime. However, you can run the test many times to be sure. Each time you repeat it, the chance of being wrong gets much smaller. The Miller-Rabin test is a very popular way to do this.

There are many different kinds of these tests. The Fermat primality test is one of the simplest. It is often used for a quick screening of numbers. Some special numbers, called Carmichael numbers, can even trick this test. The Miller-Rabin and Solovay-Strassen tests are more advanced. They are better at catching composite numbers. Another method is the Baillie-PSW test. It combines different tests to be even more accurate.

Math is always growing and finding new ways to solve puzzles. Some tests are called deterministic, which means they give a certain answer. The elliptic curve primality test is one such method. It can even produce a certificate to prove a number is prime. In the future, quantum computers might change how we do this math. They could potentially test numbers even faster than today's computers. It is amazing how much math goes into one simple question.

389 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

More to explore

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.