We can test numbers. Some numbers are special. We check if they can be split up. This helps us keep secrets safe. It is a fun math game. Can you find a special number?
Some numbers are special. We call them prime. A prime number cannot be split into equal groups. We can use tests to find them. One way is to try dividing. We check if other numbers fit into it. If they do, the number is not prime. If no numbers fit, it is prime. This is like checking if a shape can be broken. These tests help keep our secrets safe online. It is a great way to use math.
How do we know if a number is prime? A prime number is a number that cannot be split into equal groups. A primality test is a set of steps to find this out. These tests help keep our secrets safe in cryptography. This is the math used to protect data online.
One simple way is called trial division. You try to divide your number by other numbers. You only need to check primes up to the square root of your number. For example, if you check 17, you only test 2 and 3. Neither works, so 17 is prime. If you check 221, you find that 13 fits. This means 221 is composite, which means it is not prime.
Some tests are faster but use luck. These are called probabilistic tests. They pick a random number to test your number. These tests might say a number is prime when it is not. However, you can run the test many times to be sure. The Miller-Rabin test is a very popular way to do this. It is much faster than other methods.
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.
A primality test is a mathematical algorithm used to determine if a specific number is prime. A prime number is a positive integer greater than 1 that has no divisors other than 1 and itself. These tests are essential in modern mathematics and computer science. They are used heavily in cryptography to secure digital communications. While integer factorization seeks to find the specific prime factors of a number, a primality test only identifies if the number is prime or composite. Factorization is considered a computationally difficult problem. In contrast, primality testing is comparatively easy because its running time is polynomial relative to the size of the input.
The most basic method is known as trial division. To use this, you divide the input number, n, by every prime number between 2 and the square root of n. If any of these divisions leave no remainder, the number is composite. If no such divisors are found, the number is prime. This works because every divisor pair of a number must contain at least one divisor less than or equal to its square root. For example, testing the number 221 requires checking primes up to 14. Since 13 divides 221, the number is proven to be composite. Testing 17 only requires checking 2 and 3, which proves 17 is prime.
Mathematicians have developed ways to make trial division more efficient. One method is to test divisibility by 2 and 3, then only check numbers of the form 6k ± 1. This is nearly three times faster than checking every number. Another strategy is to use a primality sieve, like the Sieve of Eratosthenes, to pre-compute a list of small primes. By checking a large number against a stored list of primes up to 200, you can quickly identify many composite numbers. This allows you to skip much more complex tests if a small prime factor is found immediately.
Some tests are categorized as heuristic tests. These methods appear to work well in practice, but they are unproven and are not technically considered true algorithms. An example is the Fermat primality test. This test uses the property that if n is prime, then a raised to the power of n minus 1 is congruent to 1 modulo n. If this equality fails, the number is definitely composite. However, some composite numbers, called pseudoprimes, can pass this test. Even more tricky are Carmichael numbers, like 561, which pass the Fermat test for every number coprime to them.
Probabilistic tests are more rigorous than heuristics because they provide provable bounds on error. These tests choose a random number, called a witness, to test against the input n. If the test fails, n is certainly composite. If the test passes, n is declared "probably prime." The probability of error decreases as you repeat the test with different random witnesses. For the Miller-Rabin test, at least half of all possible witnesses will detect a composite number. By repeating the test k times, the error probability drops to at most 2 to the power of negative k.
The Miller-Rabin and Solovay-Strassen tests are two highly regarded probabilistic methods. The Miller-Rabin test is a strong probable prime test that is very efficient. The Solovay-Strassen test uses the Jacobi symbol to check for primality. While the Solovay-Strassen test is useful, the Miller-Rabin test is generally considered more powerful. For instance, the number 1905 is an Euler pseudoprime to base 2, meaning Solovay-Strassen might not catch it, but Miller-Rabin will correctly identify it as composite. The Baillie-PSW test combines these ideas to create a test with no known counterexamples for numbers up to 2 to the 64th power.
Finally, there are deterministic tests that provide absolute certainty without probability. The elliptic curve primality test is one such method. It is an errorless algorithm that can produce a primality certificate to prove a number is prime. Although it is slower than probabilistic tests, it is mathematically definitive. In the future, the field may change with the rise of quantum computers. Using Shor's algorithm alongside the Pocklington primality test, quantum machines could potentially solve these problems much faster than classical computers can today.
More to explore
✨ What else?
Related topics you might enjoy
🔬 Go deeper
More advanced topics to explore
🪜 Step back
Simpler topics to build understanding
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.