Prime Number Checker
How This Converter Works
Checks whether an entered decimal integer of at most 20 digits is prime. Surrounding whitespace is trimmed, blank input clears the result, and non-decimal or overlong input displays Invalid input. Values below 2 are not prime.
Formula or rule
For n <= 2^53 - 1, test 2, 3, then divisors 6k - 1 and 6k + 1 through floor(sqrt(n)); for larger inputs, use BigInt divisibility checks and Miller-Rabin with the first 12 prime bases.
Example
- Input
- 29
- Calculation
- 29 is greater than 1; neither 2 nor 3 divides it, and no 6k +/- 1 divisor through floor(sqrt(29)) = 5 divides it.
- Result
- 29 - Prime Number
Notes
The input field accepts up to 20 characters. BigInt avoids precision loss above JavaScript’s safe-integer limit, and the selected Miller-Rabin bases give exact results throughout this 20-digit input range.