Prime Number Checker

Determine if a number is prime and factor it into primes.

Result

✗
2 × 2 × 2 × 3 × 3 × 5

How it is calculated

The tool uses trial division. It tries each divisor p starting from 2 while p × p ≤ x, and every time p divides the remaining number x evenly it records p as a factor and divides it out. Whatever is left above 1 at the end is itself a prime factor.

If exactly one factor is collected, the number is prime and shows ✓, with the number itself as its only factor. Otherwise it shows ✗ and lists the prime factors with repeats, multiplied together to give the original number. Only whole numbers of 2 or more are accepted; 0, 1, negatives and numbers with a decimal part give no result, and neither do numbers of 253 (9,007,199,254,740,992) or more, which cannot be held exactly. Searching only up to the square root is enough, since a composite number always has a prime factor no larger than it.

Worked example

Check 360.

  1. 360 / 2 = 180, / 2 = 90, / 2 = 45: three factors of 2
  2. 45 / 3 = 15, / 3 = 5: two factors of 3
  3. 5 remains and is prime: one factor of 5

Six factors were found, so the number is not prime (✗) and the factorization is 2 × 2 × 2 × 3 × 3 × 5, which equals 2³ × 3² × 5 = 360.

Try this example →

Common mistakes

  • Treating 1 as prime: it has only one divisor and the tool gives no result for it, as it does for 0 and negative numbers.
  • Expecting a factor list for a prime: a prime shows ✓ with the number itself as the single factor.
  • Assuming odd numbers are prime: 9, 15, 21 and 25 are odd and composite.
  • Entering a number with a decimal part (such as 12.5) or thousands separators: only plain whole numbers are accepted, and the tool stops at 9,007,199,254,740,992 (253) with no result.

About this calculator

This tool checks whether a number is prime — meaning it has no positive divisors other than 1 and itself — by testing it against candidate divisors, and if the number is not prime, it also breaks the number down into its prime factorization, the unique set of prime numbers that multiply together to produce it. Every whole number greater than 1 is either prime or can be expressed as exactly one such product, a fact known as the fundamental theorem of arithmetic.

It is used by students learning number theory and working through factoring problems, and by programmers and hobbyists exploring topics like cryptography, where the difficulty of factoring very large numbers into their prime components underpins the security of algorithms like RSA. It also comes up in simpler practical contexts, like reducing a fraction to lowest terms or finding the least common multiple of two numbers, both of which rely on knowing prime factorizations.

Was this helpful?

You can pick up to 3 reactions.

Comments (1)

  • Editorial team

    The factor list is useful beyond primes: to reduce 84/126, factor both. 84 is 2 × 2 × 3 × 7 and 126 is 2 × 3 × 3 × 7, so cancel 2 × 3 × 7 = 42 and you are left with 2/3. The tool stops at 9,007,199,254,740,992 and above and shows no result there, since larger integers are no longer held exactly. Do you use it for fractions, homework or cryptography exercises?

Popular calculators

All Calculators