Prime Number Checker

This calculator tells you instantly whether any whole number is prime or composite, and shows the maths behind the answer. Enter a positive whole number, or pick one of the quick examples such as 97, 100, or the special case of 1, and the checker uses trial division up to the square root of your number to test every possible divisor. You get a verdict tile showing whether the number is prime, composite, or a special case like 0 or 1, along with the total number of factors and the number of divisors tested. Below that, two detail panels list the number's full factor list, its square root and whether it is even, plus its prime factorisation, the next prime above it, and the nearest prime below it. A worked example walks through the default number of 97 step by step, showing exactly which divisors were tested and why none of them divided evenly. Use this tool to settle a maths question, check homework, explore how prime factorisation works, or find the primes nearest to a given number. It handles positive integers up to about 10 trillion reliably; beyond that, results may slow down or lose precision because of how browsers handle very large integers, so specialist software using algorithms such as Miller-Rabin suits genuinely huge numbers used in cryptography.

Calculate.co.nz is proud to be partnered with Health Based Building, a leader in sustainable and health-conscious building innovation. With over a century of experience, they develop high-performance systems like Foreverbreathe Specification, Magnum Board, and Foreverbreathe Paints to support energy-efficient, non-toxic living environments. Their commitment to healthier homes aligns with our belief that informed choices lead to better outcomes for Kiwi households.
Calculate.co.nz partner: Health Based Building
Standard Method  Trial division to sqrt(n). Valid for all positive integers.

1. Enter a Number

2. What This Checks

A prime number has exactly two divisors: 1 and itself. This checker tests every candidate divisor from 2 up to the square root of your number. If none divide evenly, the number is prime.

For the number 97: the square root is about 9.85, so we only need to check divisors 2, 3, 5, 7. None divide 97 evenly, so 97 is prime.

Result

Verdict
Prime
Has exactly 2 divisors
Number of Factors
2
Including 1 and itself
Divisors Tested
9
Up to sqrt(n)

Number Details

Your number97
ClassificationPrime
Is even?No
Square root9.849
Divisors tested up to9
All factors2 factors
Factor List
197

Prime Factorisation

Number97
Is prime?Yes
Prime factorisation97
Next prime after n101
Previous prime before n89
Nearest primes89 and 101
Verdict: 97 is a prime number. It has exactly 2 factors: 1 and 97. No whole number between 2 and 9 divides it evenly.

Worked Example: Is 97 prime?

Step 1: Find the square root of 97. sqrt(97) = 9.849, so we only need to test divisors from 2 up to 9.

Step 2: Test each candidate: 97 / 2 = 48.5 (no), 97 / 3 = 32.33... (no), 97 / 5 = 19.4 (no), 97 / 7 = 13.86... (no).

Step 3: No whole-number divisor was found between 2 and 9. Therefore 97 is prime. Its only factors are 1 and 97.

This matches the calculator output above with the default value of 97.

What Is a Prime Number?

A prime number is a whole number greater than 1 that cannot be divided evenly by any number except 1 and itself. The first ten primes are 2, 3, 5, 7, 11, 13, 17, 19, 23, and 29. Prime numbers are the building blocks of all whole numbers: every integer greater than 1 can be written as a unique product of primes (the Fundamental Theorem of Arithmetic).

A composite number is a positive integer greater than 1 that has at least one divisor other than 1 and itself. For example, 12 = 2 x 2 x 3. The number 1 is neither prime nor composite by mathematical convention.

How Trial Division Works

The most straightforward primality test is trial division. To test whether n is prime, you divide n by every integer from 2 up to the square root of n. If any of these divisions has a whole-number result (no remainder), n is composite. If none do, n is prime.

Why stop at the square root? If n has a factor d greater than sqrt(n), then n / d is a factor smaller than sqrt(n), and you would already have found it during the earlier tests. So there is no need to test beyond the square root.

Example: for n = 36, sqrt(36) = 6. Testing 2, 3, 4, 5, 6 finds that 2 and 3 both divide 36, so 36 is composite. Its prime factorisation is 2 x 2 x 3 x 3 = 2² x 3².

Special Cases

NumberClassificationReason
1Neither prime nor compositeHas only one positive divisor (itself)
2PrimeThe only even prime; divisible only by 1 and 2
0Neither prime nor compositeNot a positive integer; divisible by every non-zero integer
Negative integersNot applicablePrimality is defined for positive integers only

Prime Numbers and Cryptography

Large prime numbers underpin modern cryptography. RSA encryption relies on the fact that multiplying two large primes is easy, but factoring the result back into its prime components is computationally hard. A typical RSA key uses primes with hundreds of digits. The difficulty of finding prime factors of very large numbers is the mathematical foundation of secure internet transactions.

Related Calculators

Method: Trial division to floor(sqrt(n)). For each candidate divisor d from 2 to floor(sqrt(n)), the checker tests whether n mod d = 0. If any remainder is zero, n is composite and all factors are listed. If no divisor is found, n is prime. Prime factorisation uses repeated division by the smallest prime factor until the quotient reaches 1.

This checker handles positive integers. Very large numbers (above 10 trillion) may be slow to process in some browsers due to JavaScript integer precision limits. For cryptographic-grade primality testing of extremely large numbers, specialist tools using probabilistic algorithms such as Miller-Rabin are recommended.