Prime Checker
Use this Prime Checker to enter signed decimal integers through ±(2^64 - 1) and review exact BigInt primality results.
Results are calculated automatically as you enter data.
↓ See explanations and tips below ↓
Related Calculators
What Is a Prime Number?
A prime number is a whole number greater than 1 that has exactly two positive divisors: 1 and itself. For example, 2, 3, 5, 7, 11, and 13 are prime because each of them can be divided evenly only by 1 and by the number itself.
A composite number is a whole number greater than 1 that has more than two positive divisors. For example, 12 is composite because it is divisible by 1, 2, 3, 4, 6, and 12. The number 1 is neither prime nor composite because it has only one positive divisor.
Prime checking is the process of deciding whether a whole number fits the definition of a prime number. Instead of listing every possible factor, a prime-checking method can test divisibility in a more organized way.
Why Prime Numbers Matter
Prime numbers are often called the building blocks of whole numbers because composite numbers can be broken down into products of primes. This idea appears in many areas of math, including fractions, greatest common divisors, least common multiples, factoring, modular arithmetic, and number theory.
Prime numbers are also useful because they help answer practical questions such as:
- Can this number be split into equal groups?
- Does this number have a hidden factor?
- What are the prime factors of a larger number?
- Which numbers should be tested when checking divisibility?
For students, prime checking is a good way to practice divisibility, factor pairs, square roots, and logical reasoning.
Key Terms to Know
- Whole number: A number with no fractional or decimal part, such as 0, 1, 2, 17, or 100.
- Divisor: A number that divides another number evenly.
- Factor: A divisor that forms a whole-number product with another factor. For example, 4 and 9 are factors of 36 because \(4 \times 9 = 36\).
- Prime number: A whole number greater than 1 with exactly two positive divisors: 1 and itself.
- Composite number: A whole number greater than 1 with more than two positive divisors.
- Trial division: An educational method for checking possible divisors; it is not the production method for the largest supported values.
- Miller-Rabin test: A modular-exponentiation test run with fixed deterministic bases sufficient for the signed 64-bit magnitude domain.
- Supported range: Signed decimal integers whose magnitude is at most 2^64 - 1, parsed exactly as BigInt.
How Prime Checking Works
To decide whether a number \(n\) is prime, the goal is to find out whether any whole number other than 1 and \(n\) divides it evenly. In mathematical notation, a divisor \(d\) divides \(n\) evenly when the remainder is 0:
The calculator first parses trimmed text as signed decimal digits. Decimal points, exponents, hexadecimal notation, malformed text, and non-finite values return Enter decimal digits only.; magnitudes above 2^64 - 1 return Enter a whole number within the supported 64-bit range..
For accepted BigInt values, numbers below 2 are Not prime. Small-prime shortcuts run first, followed by deterministic Miller-Rabin fixed bases proven sufficient for the signed 64-bit magnitude domain.
Trial division can illustrate why a small factor proves compositeness, but it is explicitly educational only and is not the production algorithm for large supported values.
The deterministic Miller-Rabin rounds use modular exponentiation rather than a square-root divisor loop, so exact supported values remain practical near the 64-bit boundary.
Examples of Prime Checking in Practice
The following square-root and trial-division examples are educational illustrations only; production checks use the deterministic Miller-Rabin method described above.
Example 1: Checking a Prime Number
Suppose you want to check whether 29 is prime.
First find the divisor limit:
Round down:
Since 29 is not even, test the odd divisors 3 and 5:
No tested divisor divides 29 evenly, so 29 is prime.
Example 2: Checking a Composite Number
Suppose you want to check whether 45 is prime.
The square root is:
So only divisors up to 6 need to be considered. Since 45 is odd, test odd divisors:
Because 3 divides 45 evenly, 45 is composite. It is not prime.
Example 3: A Square-Number Edge Case
The number 49 is a useful edge case because its important factor is exactly its square root:
Testing only 3 and 5 would miss the factor 7, so the square-root limit must include the endpoint:
Because 7 divides 49 evenly, 49 is not prime.
How to Interpret the Result
A result of Prime means the entered supported signed integer is greater than 1 and passes the small-prime shortcuts and deterministic Miller-Rabin test.
A result of Not prime means one of two things is true:
- The number is below 2, such as 0, 1, or a negative integer.
- The number has at least one divisor other than 1 and itself.
An em dash, —, means the input is empty, so no prime-checking result has been calculated yet.
A validation message means the value cannot be checked under the calculator’s input rules:
- Enter decimal digits only. means the value is malformed, decimal, exponential, hexadecimal, or non-finite.
- Enter a whole number within the supported 64-bit range. means the integer magnitude is greater than 2^64 - 1.
The result is a status, not a factorization. If the result is Not prime, it does not necessarily show which divisor proves the number is composite.
Common Mistakes and Misconceptions
Mistake 1: Assuming 1 is prime.
The number 1 is not prime because it does not have exactly two positive divisors. It has only one positive divisor: itself.
Mistake 2: Assuming every odd number is prime.
Odd numbers are not automatically prime. For example, 9, 15, 21, 25, 27, and 45 are all odd composite numbers.
Mistake 3: Entering decimals.
Prime numbers are defined for whole numbers greater than 1. A value such as 7.5 is not checked as prime because it is not a whole number.
Mistake 4: Testing too many divisors.
As an educational trial-division shortcut, a composite number has a factor at or below \(\sqrt{n}\); this is not the production algorithm used for large supported inputs.
Mistake 5: Testing too few divisors.
The square-root endpoint matters. For perfect squares such as 49 or 121, the repeated factor is exactly the square root.
Mistake 6: Expecting a factor list.
A prime checker answers whether the number is prime. A factor calculator or prime factorization calculator is better when you need the actual factors.
When to Use Prime Checking
Use prime checking when you need to know whether a whole number has any divisors besides 1 and itself.
Common uses include:
- Checking math homework involving prime and composite numbers.
- Preparing for prime factorization.
- Finding numbers that may be useful in divisibility problems.
- Understanding factor pairs and square roots.
- Learning the logic behind simple primality tests.
- Checking small or moderate whole numbers before using them in another calculation.
Prime checking is especially helpful as a first step before using related ideas such as greatest common divisor, least common multiple, and prime factorization.
Limitations and Things to Keep in Mind
Prime checking depends on valid input. This calculator accepts signed decimal integers with magnitude through 2^64 - 1 and parses them as exact BigInt values. Decimal values, exponents, malformed text, non-finite values, and larger magnitudes are rejected.
The production method uses small-prime shortcuts followed by deterministic Miller-Rabin fixed bases for signed values with magnitude through 2^64 - 1. Trial division is included only as an educational idea.
The output is text-only. It tells you whether the number is Prime, Not prime, or invalid for the calculator’s rules, but it does not show a full proof, all factor pairs, or prime factorization steps.
The production result does not use a square-root divisor loop. The page’s square-root examples are educational explanations of trial division only.
How to Use This Calculator
- Enter a signed decimal integer in the input field.
- Read the live result shown in the result area.
- Use Prime to identify a supported signed integer greater than 1 that passes deterministic Miller-Rabin.
- Use Not prime to identify values below 2 or composite whole numbers.
- If a validation message appears, use decimal digits only and keep the magnitude at or below 2^64 - 1.
Frequently Asked Questions
Is 1 a prime number?
No. A prime number must have exactly two positive divisors: 1 and itself. The number 1 has only one positive divisor, so it is neither prime nor composite.
Is 2 a prime number?
Yes. The number 2 is prime because its only positive divisors are 1 and 2. It is also the only even prime number.
Why do you only need to check divisors up to the square root?
If a number is composite, it can be written as a product of two smaller factors. At least one of those factors must be less than or equal to the square root of the number. If no divisor is found by that point, no larger divisor can appear without a smaller partner that was already missed.
Does a prime checker work for decimals?
No. Prime numbers are defined for whole numbers greater than 1. Decimal and fractional values should not be treated as prime or composite in this context.
What does “Not prime” mean?
“Not prime” means the value is below 2 or has a divisor other than 1 and itself. For example, 1 is not prime because it is below 2, while 21 is not prime because it is divisible by 3 and 7.
Why are very large integers outside the supported range rejected?
The calculator uses exact BigInt parsing, so values such as 2^53 + 1 are supported. It rejects magnitudes above 2^64 - 1 so the deterministic Miller-Rabin guarantee remains explicit and bounded.
Sources and References
Books
- Lynn Marecek, MaryAnne Anthony-Smith, and Andrea Honeycutt Mathis. Prealgebra 2e. OpenStax, 2020. Sections 2.4, “Find Multiples and Factors,” and 2.5, “Prime Factorization and the Least Common Multiple.” https://openstax.org/books/prealgebra-2e/pages/2-4-find-multiples-and-factors
- Donna Kirk. Contemporary Mathematics. OpenStax, 2023. Section 3.1, “Prime and Composite Numbers.” https://openstax.org/books/contemporary-mathematics/pages/3-1-prime-and-composite-numbers
Online and Official Sources
- MDN Web Docs. “BigInt.” https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt
- MDN Web Docs. “BigInt.asUintN().” https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/asUintN