Prime Number Test Calculator

This prime number test calculator checks whether any whole number you choose is prime, meaning it can only be divided evenly by 1 and itself, or composite, meaning a smaller number divides into it exactly. Enter a whole number up to one billion into the single field, and the result updates instantly as you type, with no need to press submit. It returns three results: a plain statement of whether your number is prime, the classification as prime or composite, and, where the number is composite, its smallest divisor, the smallest number greater than 1 that divides evenly into it. Under the hood, the calculator uses trial division, testing whether 2 divides your number evenly and then checking every odd number up to its square root, the standard, exact method for settling primality at this scale. Prime numbers, those with no divisors besides 1 and themselves, sit at the centre of number theory and underpin much of modern cryptography, hashing and computer science, so this tool suits students working through maths homework, programmers testing edge cases, and anyone curious whether a particular number is prime. Try a small prime like 97 or a composite number like 91 to see how the smallest divisor is reported, and enter as many numbers as you like.

Calculate.co.nz is proud to be partnered with realtor.co.nz, a trusted resource for navigating the New Zealand property market. Their Helpful Articles section offers clear, well-structured insights across buying, selling, and building, making complex real estate topics more accessible. With a focus on up-to-date guidance and practical knowledge, they empower Kiwis to move forward with clarity and confidence in a constantly evolving property landscape.
Calculate.co.nz partner: realtor.co.nz
97 is prime
Smallest divisor (if composite)none
Classificationprime

The formula

A number n greater than 1 is prime if no integer from 2 up to the square root of n divides it evenly. If any does, n is composite and that divisor is a proper factor.

Worked example

97 is not divisible by 2, 3, 5 or 7, and the square root of 97 is under 10, so there is nothing left to test: 97 is prime. By contrast 91 = 7 times 13, so its smallest divisor is 7. Enter 97 or 91 to confirm.

Frequently asked questions

What makes a number prime?

It is a whole number above 1 whose only divisors are 1 and itself, such as 2, 3, 5, 7 and 11.

Is 1 prime?

No. By definition a prime has exactly two distinct divisors. The number 1 has only one, so it is neither prime nor composite.

How does the test work?

It tries dividing by 2 and the odd numbers up to the square root of n. If none divide evenly, n is prime.

Who this calculator is for

This calculator is for students, programmers and anyone exploring number theory.

What this calculator assumes

  • You enter a whole number within the stated range.
  • The exact integer algorithm is used.
  • Very large results are shown grouped for readability.

Formula and sources

Related calculators