Toolzent

Prime Number Calculator

Free prime number calculator that checks if any whole number is prime or composite using trial division to the square root, and shows the full prime factorization.

Updated 2026-06-09 · Free · No sign-up · Runs privately in your browser

What does the prime number calculator do?

This prime number calculator tells you whether a whole number is prime or composite, and if it is composite it shows the full prime factorization. Type a number, press Check, and you get an instant verdict. Enter 97 and it reports prime; enter 91 and it reports composite along with 91 = 7 × 13.

A prime number is a whole number greater than 1 that is divisible only by 1 and itself. A composite number is a whole number greater than 1 that has at least one other divisor. The two special cases, 0 and 1, are neither prime nor composite, and the tool labels them as not prime. Everything runs locally in your browser, so the numbers you check never leave your device.

How does the prime check work?

The calculator uses trial division up to the square root of the number. In plain terms, it tries to divide your number by each candidate from 2 upward, and it only needs to go as far as √n.

The rule it applies is:

prime = divisible only by 1 and itself (checked by trial division to √n)

Here is why the square root is the cutoff. If a number n has a divisor d that is larger than √n, then n ÷ d is a co-factor smaller than √n — and that smaller co-factor would already have been found. So once you have tested every integer from 2 up to √n without finding a divisor, the number must be prime. This keeps the check fast even for fairly large numbers.

If a divisor is found, the number is composite, and the tool keeps factoring. It divides out each prime factor as many times as it goes in, recording the count as an exponent. The result is written in the standard form a^x × b^y × …, where each base is a prime and each exponent is how many times that prime appears.

A couple of terms worth knowing: a factor (or divisor) is a number that divides evenly with no remainder, and a prime factorization is the unique product of primes that equals your number. By the fundamental theorem of arithmetic, every whole number above 1 has exactly one prime factorization.

Examples

Each example below is exactly what the calculator returns.

  • 91 — composite. Trial division finds 91 ÷ 7 = 13, so 91 = 7 × 13. Both 7 and 13 are prime, so that is the complete factorization. Note the calculator only needed to test up to √91 ≈ 9.5.
  • 97 — prime. Testing 2, 3, 5 and 7 (every prime up to √97 ≈ 9.8) finds no divisor, so 97 is prime.
  • 360 — composite. Dividing repeatedly gives 360 = 2^3 × 3^2 × 5. That is 8 × 9 × 5 = 360, with the exponents counting how many times each prime appears.
  • 1 — not prime. The number 1 has only a single divisor, so it fails the two-divisor definition. The tool reports 1 is not prime.

You can reproduce any of these by typing the number into the calculator above and pressing Check.

Prime and composite reference table

This table lists every whole number from 2 to 20 and how the calculator classifies it. Composite entries show the factorization the tool would display.

NumberPrime or compositeFactorization
2Prime
3Prime
4Composite2^2
5Prime
6Composite2 × 3
7Prime
8Composite2^3
9Composite3^2
10Composite2 × 5
11Prime
12Composite2^2 × 3
13Prime
14Composite2 × 7
15Composite3 × 5
16Composite2^4
17Prime
18Composite2 × 3^2
19Prime
20Composite2^2 × 5

There are eight primes between 2 and 20: 2, 3, 5, 7, 11, 13, 17 and 19. Notice that 2 is the only even prime — every larger even number is divisible by 2 and so is composite.

What are prime numbers used for?

Primes are not just a classroom curiosity; they underpin a surprising amount of everyday technology and maths.

  • Cryptography. Public-key encryption (such as RSA) relies on the fact that multiplying two large primes is easy, but factoring the product back is extremely hard. This protects banking, messaging and HTTPS traffic.
  • Fractions and number theory. Prime factorization is the engine behind finding the greatest common factor and least common multiple, which simplify fractions and add them on a common denominator.
  • Hashing and computing. Prime-sized tables and prime multipliers help spread data evenly and reduce collisions in hash functions.
  • Coding and puzzles. Checking primality is a classic programming exercise, and primes show up in cicada life cycles, gear ratios and random-number design.

For related whole-number work, prime factorization feeds directly into the LCM and GCF calculator.

Tips and common mistakes

  • 1 is not prime. This trips up a lot of people. A prime needs exactly two distinct divisors, and 1 has only one, so it is excluded by definition.
  • 2 is prime, and it is the only even prime. Do not assume every prime is odd; 2 breaks that pattern.
  • You only need to test up to √n. When checking by hand, stop at the square root. To test 97 you only check primes up to 9 — there is no need to keep going.
  • Read the exponents carefully. In 360 = 2^3 × 3^2 × 5, the exponent on 5 is 1 (written plainly), while 2 appears three times and 3 appears twice.
  • Composite does not mean “not a factor of anything.” Every composite breaks down into primes, and that breakdown is unique.

Limitations and notes

This tool is built for whole numbers (non-negative integers). It does not classify decimals, fractions or negative numbers as prime, and it treats 0 and 1 as not prime by definition. Trial division is exact and reliable for the everyday range of numbers used in schoolwork and general maths, though checking an extremely large number takes longer because there are more divisors to test up to its square root.

Everything is computed privately in your browser using standard integer math, so nothing is uploaded or stored. Results are intended for educational and general reference use; for cryptographic-strength primality testing of very large numbers, specialised probabilistic algorithms are used instead of plain trial division.

For more whole-number tools, try the modulo calculator to find remainders when one number divides another, the proportion calculator for scaling ratios, the percentage calculator for quick proportional work, or browse the full math calculators category.

Frequently asked questions

How does this prime number calculator check if a number is prime?+

It uses trial division: it tests whether the number has any divisor from 2 up to its square root. If none divides evenly, the number is prime; otherwise it is composite.

Is 1 a prime number?+

No. The number 1 is neither prime nor composite, because a prime must have exactly two distinct divisors and 1 has only one. The calculator reports 1 as not prime.

Is 0 a prime number?+

No. Zero is divisible by every number, so it is not prime. Prime numbers are defined for whole numbers of 2 or greater.

What is the prime factorization of 360?+

360 = 2^3 × 3^2 × 5. The calculator shows this breakdown automatically because 360 is composite.

Why does the calculator only test divisors up to the square root?+

If a number has a factor larger than its square root, the matching co-factor must be smaller than the square root, so checking up to √n catches every divisor with far less work.

What is the difference between prime and composite?+

A prime number has exactly two divisors, 1 and itself, while a composite number has at least one extra divisor. For example 97 is prime and 91 is composite (91 = 7 × 13).

Is 2 really a prime number?+

Yes. Two is the smallest prime and the only even prime, because every other even number is divisible by 2 and therefore composite.