dCode is free and its tools are a valuable help in games, puzzles and problems to solve every day!You have a problem, an idea for a project, a specific need and dCode can not (yet) help you? You need custom development? Contact-me!

Message for dCode's author:

Team dCode read all messages and answer them if you leave an email (not published). It is thanks to you that dCode has the best Primality Test tool. Thank you.

Primality Test

Prime Number Tester

Tool to check if a number is a prime number. A primality test is a mathematical and algorithmic test that indicates whether a number is prime or compound and answers true or false.

Answers to Questions

How to know if a number is a prime?

To know if a number is prime, check if it has any divisor except 1 or itself, this test is called a primality test. The test first uses probabilistic algorithms and if the probability of being prime is non-zero, the algorithms become deterministic (careful verification of potential divisors).

Example: Is 23456789 a prime number ? True

Example: Is 123456789 a prime number ? False

What are primality tests algorithms?

It exists several test to know if a number is a prime number : Miller–Rabin or Lucas-Lehmer are the one used by dCode.

Why 1 is not a prime number?

It is mainly a mathematical convention that avoids many problems in mathematical definitions and theorems (where one would have to exclude 1 or treat it as a special case). Another advantage is that the prime factor decomposition is unique 6 = 2*3 and not 1*2*3 or 1*1*1*2*3.