Skip to main content
HS Calculadora
Math

Prime Number Checker

Check whether your number is prime and find neighbouring primes or list primes up to your chosen limit.

Quick answer

Check whether your number is prime and find neighbouring primes or list primes up to your chosen limit. Formula: A prime integer has exactly two positive divisors: one and itself.

29 is prime; the previous prime is 23, the next is 31 and there are 10 primes up to 29.

Results update as you type.

Is prime?
Yes
Next prime31
Previous prime23
Primes up to n10

How it works

A prime integer has exactly two positive divisors: one and itself. Trial division only needs candidate factors up to the square root because any larger factor has a smaller partner. A sieve also counts all primes up to the entered number. The supported range is two through one million. This is exact integer arithmetic within that bound, not a probabilistic test for cryptographic integers. For two there is no preceding prime, so the previous-prime result is a text label. Use it to check number-theory exercises, locate neighbouring primes or compare the density of primes over small ranges. It answers a different question from prime factorisation, which decomposes a composite number into its prime factors. Remember that one is neither prime nor composite. The next and previous results are strictly beyond or below the input, even if the input itself is prime. The counting result includes the input when it is prime. Inputs are Integer to test. Results show Is prime?, Next prime, Previous prime, Primes up to n. 29 is prime; the previous prime is 23, the next is 31 and there are 10 primes up to 29.

Formula

n is prime if no integer d in [2,√n] divides n

A prime integer has exactly two positive divisors: one and itself. Trial division only needs candidate factors up to the square root because any larger factor has a smaller partner. A sieve also counts all primes up to the entered number. The calculation uses n is prime if no integer d in [2,√n] divides n.

Source:OpenStax: Algebra and Trigonometry; standard algebraic identities

We review all our tools from time to time to ensure accuracy.

Worked example

Integer to test:29
29 is prime; the previous prime is 23, the next is 31 and there are 10 primes up to 29.

How to use this calculator

  1. 1

    Enter your values

    Enter integer to test.

  2. 2

    Adjust the options

    Fine-tune any options to match your situation.

  3. 3

    Read your result

    Is prime? updates instantly as you type — no button to press.

Frequently asked questions

How does the prime number checker calculation work?

A prime integer has exactly two positive divisors: one and itself. Trial division only needs candidate factors up to the square root because any larger factor has a smaller partner. A sieve also counts all primes up to the entered number. The model is written as n is prime if no integer d in [2,√n] divides n.

Which inputs and units should I use?

Inputs are Integer to test. Results show Is prime?, Next prime, Previous prime, Primes up to n. Remember that one is neither prime nor composite. The next and previous results are strictly beyond or below the input, even if the input itself is prime. The counting result includes the input when it is prime.

What are the limits of this calculation?

The supported range is two through one million. This is exact integer arithmetic within that bound, not a probabilistic test for cryptographic integers. For two there is no preceding prime, so the previous-prime result is a text label. Remember that one is neither prime nor composite. The next and previous results are strictly beyond or below the input, even if the input itself is prime. The counting result includes the input when it is prime.

When is this result useful?

Use it to check number-theory exercises, locate neighbouring primes or compare the density of primes over small ranges. It answers a different question from prime factorisation, which decomposes a composite number into its prime factors. A prime integer has exactly two positive divisors: one and itself. Trial division only needs candidate factors up to the square root because any larger factor has a smaller partner. A sieve also counts all primes up to the entered number.

How can I check the worked example?

29 is prime; the previous prime is 23, the next is 31 and there are 10 primes up to 29. Remember that one is neither prime nor composite. The next and previous results are strictly beyond or below the input, even if the input itself is prime. The counting result includes the input when it is prime.

More Math calculators

Math

Prime Factorization Calculator

Break a number into its prime factors.

Math

GCF Calculator

Find the greatest common factor of numbers.

Math

Fraction Calculator

Add, subtract, multiply or divide two fractions.

Math

System of Equations Calculator (2×2)

Solve two linear equations in two unknowns with Cramer's rule.