# Prime Number Calculator

URL: https://speedycalculator.com/calculators/math/prime-number/
Last updated: 2026-10-30

> The prime number calculator tells you whether a number is prime or composite, gives its smallest prime factor, its factorisation and the nearest primes before and after it.

## Inputs

- Number

## Results

- Result
- Smallest prime factor
- Prime factorisation
- Previous prime
- Next prime
- Reason

## Formula

```
n is prime ⇔ n > 1 and no prime p ≤ √n divides n
```

## Explanation

Primes are the atoms of arithmetic: numbers greater than 1 divisible only by 1 and themselves. Testing primality is easy even for big numbers, while factoring them is hard – the asymmetry behind modern cryptography.

### How to use the Prime Number Calculator

- **Number**

Everything is calculated in your browser, so results appear instantly and nothing you type is sent to a server.

### How it works

The calculator uses trial division by small primes and the deterministic Miller–Rabin test, which is exact for every number you can type, then finds the neighbouring primes.

## Worked example

Inputs — Number: 97.

Results — **Result = 97 is a prime number**; Prime factorisation = 97; Previous prime = 89; Next prime = 101; Reason = No prime up to √97 ≈ 9.84886 divides it..

## Key terms

- **Prime number**: A number > 1 whose only divisors are 1 and itself.
- **Composite number**: A number > 1 that is not prime.

## FAQ

**Is 1 prime?**
No – primes must have exactly two divisors.

**Is 2 prime?**
Yes, and it is the only even prime.

**How many primes are there?**
Infinitely many (Euclid's theorem).

**What is the largest known prime?**
A Mersenne prime with tens of millions of digits, found by the GIMPS project.


## Sources

- [Wolfram MathWorld – Prime number](https://mathworld.wolfram.com/PrimeNumber.html)
- [OpenStax – Contemporary Mathematics](https://openstax.org/details/books/contemporary-mathematics)
