Connect via MCP →

Enter Calculation

Formula

Advertisement

Results

The number 97 is
Prime
divisible only by 1 and itself
Number 97

What this calculator does

This tool tells you whether a whole number is prime or composite. A prime number greater than 1 has exactly two divisors: 1 and itself. A composite number has at least one additional divisor. The numbers 0 and 1 are neither prime nor composite, so the calculator expects an input of 2 or more.

How to use it

Type any whole number into the box and submit. The calculator reports the classification, and when the number is composite it also shows the smallest prime factor and an example factorization (smallest factor × the matching co-factor).

The formula explained

The check uses trial division. To decide if n is composite, you only need to test divisors d from 2 up to the square root of n. If any such d divides n with no remainder, then n is composite. If none do, n is prime. Testing only up to √n works because if n = a × b, at least one of the factors must be ≤ √n.

$$\text{Prime if } n > 1 \text{ and } \nexists\, d \in [2, \lfloor\sqrt{n}\rfloor] : n \bmod d = 0$$

$$\begin{gathered} \text{Classify}(n) = \begin{cases} \text{Prime} & \nexists\, d \in [2,\lfloor\sqrt{n}\rfloor],\; n \bmod d = 0 \\[0.4em] \text{Composite} & \exists\, d \in [2,\lfloor\sqrt{n}\rfloor],\; n \bmod d = 0 \\[0.4em] \text{Neither} & n < 2 \end{cases} \end{gathered}$$

Advertisement
Trial division checking divisors up to the square root of n
A number is composite if it has a divisor between 1 and its square root; otherwise it is prime.

Worked example

Take \(n = 91\). The square root of 91 is about 9.54, so we test 2, 3, 5, 7, 9. We find \(91 \div 7 = 13\) exactly, so 91 is composite with smallest factor 7 and factorization \(7 \times 13\). By contrast, 97 has no divisor up to 9, so it is prime.

Comparison of a prime number and a composite number as dot arrangements
A prime forms only a single row; a composite can be arranged into a full rectangle of factors.

FAQ

Is 1 prime? No. By definition a prime must have exactly two distinct positive divisors, and 1 has only one.

Is 2 prime? Yes. It is the only even prime number.

Why stop at the square root? Any factor larger than √n is paired with a smaller factor below √n, which the search already covers, so checking beyond √n is redundant.

Last updated: