๐Ÿ”Ÿ Prime Checker

Is it prime?Yes, it's prime

Enter an integer and instantly find out whether it's a prime number. If it's not prime, its prime factorization is shown too. Useful for math homework or learning the basics behind cryptography.

How to use

  1. Enter the integer you want to check (0 to 1 trillion).
  2. Whether it's prime, and its prime factorization if not, are shown automatically.

How the calculation works

A prime is an integer of at least 2 whose only divisors are 1 and itself. To test whether n is prime, it is enough to check for divisors from 2 up to โˆšn: if n had a divisor larger than โˆšn, its partner divisor would have to be smaller than โˆšn, so the larger range never needs checking. This tool goes further. After ruling out 2 and 3, it only tries numbers of the form 6k โˆ’ 1 and 6k + 1 (5, 7, 11, 13, 17, 19, โ€ฆ). Every prime above 3 has that form, because 6k, 6k+2, 6k+3 and 6k+4 are all divisible by 2 or 3, so this cuts the number of trial divisions to about a third. For composite numbers, the prime factorisation is shown as well, found by trial division โ€” dividing out each factor as many times as it goes, smallest first.

Worked example

Is 221 prime? 1. โˆš221 โ‰ˆ 14.87, so checking divisors up to 14 is enough 2. Not divisible by 2 or 3 3. Try the 6kยฑ1 candidates: 5 no, 7 no, 11 no, 13 โ†’ 221 รท 13 = 17, divides exactly 221 is not prime: 221 = 13 ร— 17. 223, by the same process, has no divisor up to 14 and is therefore prime.

Things to be aware of

  • 1 is not prime; the definition requires an integer of at least 2.
  • Integers up to one trillion are supported. Larger values would put too heavy a load on the browser.
  • Negative numbers and decimals cannot be tested for primality.
  • Testing the hundreds-of-digits primes used in cryptography calls for different methods, such as probabilistic primality tests. This tool is for learning and quick checks.

FAQ

Is 1 a prime number?

No. By definition, a prime number is a natural number greater than 1 with no divisors other than 1 and itself, so 1 doesn't qualify.

How large a number can this check?

Integers up to 1 trillion (1,000,000,000,000) are supported. Larger numbers are excluded since the calculation would become too slow in a browser.

What happens if I enter a negative number or a decimal?

Primality is only defined for natural numbers 2 and above, so no result is shown for negative numbers or decimals.