Nepedia
Back to Discover
Independent Reader
🔢

Primality test

math Maturity 11-13 Next article →

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.

183 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.