Home › Calculators › Prime Number Checker

Prime Number Checker

Type any whole number, even a 60-digit one, to find out if it is prime, see its prime factorization, factor tree and divisors, or list every prime in a range.

Last updated:

–
Prime factorization–
Number of divisors–
Sum of divisors–
Previous prime–
Next prime–
Euler's totient φ(n)–
Digits–
Advertisement
Advertisement

How to use the Prime Number Checker

  1. Type a number or an expression such as 2^31-1, or tap one of the examples.
  2. Press Check prime to see whether it is prime and why, with the working shown.
  3. Read the factorization, divisors and factor tree for composite numbers, and download the tree as SVG.
  4. Switch to Primes in a range, enter a start and end, and press Find primes.
  5. Copy or download the complete list of primes.

How the primality test works

A prime number is a whole number greater than 1 whose only divisors are 1 and itself. For small numbers the checker uses trial division: if no prime up to √n divides n, then n is prime. For example, √97 ≈ 9.8 and none of 2, 3, 5 or 7 divides 97, so 97 is prime.

For large numbers it uses the Miller–Rabin test with exact big-integer arithmetic. Write n − 1 = 2ˢ × d with d odd; for each base a, n passes if ad ≡ 1 (mod n) or a2ʳd ≡ −1 (mod n) for some r < s. Testing the 13 prime bases 2 to 41 is proven to be deterministic for every n below 3.3 × 10²⁴. Above that, 25 bases are used and the result is reported as a strong probable prime (the chance of error is astronomically small).

Prime factorization and factor trees

Every whole number greater than 1 can be written as a product of primes in exactly one way (the fundamental theorem of arithmetic). The tool divides out small primes first, then splits large composite parts with Pollard's rho (Brent's variant), which finds factors of 20-digit numbers in milliseconds. Example: 360 = 2 × 180 = 2 × 2 × 90 = … = 2³ × 3² × 5.

From the factorization n = p₁a × p₂b × …, the number of divisors is (a + 1)(b + 1)…, so 360 has 4 × 3 × 2 = 24 divisors. Euler's totient φ(n) counts the numbers up to n that share no factor with n.

How many primes are there?

Up toNumber of primes π(n)Largest prime below
1047
1002597
1,000168997
10,0001,2299,973
100,0009,59299,991
1,000,00078,498999,983
10,000,000664,5799,999,991

The prime number theorem says π(n) is roughly n ÷ ln(n), so primes thin out slowly but never stop: Euclid proved there are infinitely many. The range finder uses a segmented Sieve of Eratosthenes, crossing out multiples of each prime up to √(end).

Special kinds of numbers

  • Twin primes differ by 2, like 11 and 13 or 101 and 103.
  • Mersenne primes have the form 2ᵖ − 1, such as 2⁶¹ − 1 = 2,305,843,009,213,693,951.
  • Carmichael numbers such as 561 = 3 × 11 × 17 pass the simple Fermat test for every base coprime to them, which is why Miller–Rabin is used instead.
  • Semiprimes are products of two primes – the basis of RSA encryption.

Frequently asked questions

How do I know if a number is prime?

Check whether any prime up to its square root divides it evenly. If none does, it is prime. For example, 91 is not prime because 7 × 13 = 91, but 89 is prime because none of 2, 3, 5 or 7 divides it.

Is 1 a prime number?

No. A prime must have exactly two different divisors, 1 and itself. The number 1 has only one divisor, so it is neither prime nor composite. The smallest prime is 2, the only even prime.

How large a number can I check?

Up to 60 digits. Numbers below 3.3 × 10²⁴ are proven prime or composite exactly; larger ones use extra Miller–Rabin rounds and are reported as strong probable primes. Factoring very large numbers with two big prime factors may take longer than the browser allows.

What is a factor tree?

A diagram that splits a number into two factors, then splits each composite factor again, until only primes remain at the leaves. Multiplying the green prime leaves gives back the original number.

What is the Miller–Rabin test?

A fast primality test based on modular exponentiation. Each base either proves a number composite or lets it pass. With the right set of bases it is deterministic for all numbers below a known bound.

Is my number sent anywhere?

No. All calculations run in your browser with JavaScript BigInt; nothing is uploaded.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

Square Root CalculatorFind square, cube and nth roots with simplified radical form and steps.Exponent CalculatorRaise any number to a power, including negative and fractional exponents.Fraction CalculatorAdd, subtract, multiply and divide fractions with steps.Multiplication Table GeneratorPrintable multiplication charts up to 30 × 30, single tables and practice sheets.Fibonacci CalculatorExact n-th Fibonacci number (BigInt), sequence lists, Fibonacci check and golden ratio.Hundreds Chart GeneratorPrint 1-100 or 1-120 charts: full, blank or with missing numbers, with highlighted patterns.Graphing CalculatorPlot multiple functions with zoom, pan, intersections and a value table.Logarithm CalculatorCalculate log in any base, ln, log10, log2 and antilog with change-of-base steps.Quadratic Equation SolverSolve ax² + bx + c = 0 with exact roots, steps, vertex and a parabola graph.Matrix CalculatorAdd, multiply, invert and row-reduce matrices up to 5×5 with exact fractions and steps.GCF and LCM CalculatorFind the GCF and LCM of two or more numbers with Euclid steps and prime factorization.Cubic Yard CalculatorConvert length, width and depth in any unit to cubic yards, cubic feet, m³ and material weight.Factorial CalculatorExact n! up to 5000! with digit count, trailing zeros and double factorial.Prime Factorization CalculatorFind prime factors in exponent form with a factor tree, divisor count and divisors list.Modulo CalculatorCalculate a mod n and the quotient, with floored, truncated and Euclidean rules.Exponential Growth CalculatorExponential growth and decay: final amount, rate or time, discrete or continuous.Linear Regression CalculatorLeast-squares line of best fit: slope, intercept, r, r², predictions and a scatter plot.System of Equations SolverSolve 2×2, 3×3 and 4×4 linear systems with exact fractions and step-by-step working.Cubic Equation SolverSolve ax³ + bx² + cx + d = 0 for real and complex roots with steps and a graph.Summation CalculatorEvaluate sigma notation: sum any expression in n from a to b with partial sums and a chart.Arithmetic Sequence CalculatorFind the n-th term, sum and full list of an arithmetic sequence, or d from two terms.Geometric Sequence CalculatorFind the n-th term, sum and infinite sum of a geometric sequence, or r from two terms.Factors CalculatorAll factors and factor pairs of a number, prime factors, divisor count and perfect check.Depth of Field CalculatorNear and far focus limits, depth of field and hyperfocal distance for any camera or lens.Crop Factor CalculatorCrop factor, full-frame equivalent focal length and aperture, and field of view for any sensor.Completing the Square CalculatorRewrite ax² + bx + c in vertex form a(x − h)² + k step by step and solve it.Derivative CalculatorSymbolic derivative of any f(x) up to 5th order, with steps, slope at a point and a graph.Exposure Value CalculatorEV from aperture, shutter and ISO, or solve any missing setting with sunny 16 presets.Factoring Trinomials CalculatorFactor trinomials and polynomials: GCF, ac method, difference of squares, cubes, with steps.Integral CalculatorDefinite integral of f(x) from a to b with adaptive Simpson, area graph and antiderivative.Least Common Denominator CalculatorFind the LCD of two or more fractions and rewrite them as equivalent fractions, with steps.Limiting Reactant CalculatorFind the limiting reactant, theoretical yield and leftover excess from an equation.Parabola CalculatorVertex, focus, directrix, axis, intercepts and graph of a parabola from its equation.Polynomial Root FinderFind all real and complex roots of a polynomial up to degree 10, with the factored form.Prime Number List GeneratorList all primes in a range or the first N primes with a fast sieve; copy or download the list.Quadratic Regression CalculatorFit y = ax² + bx + c (or up to degree 6) to x, y data with R², predictions and a graph.Scatter Plot MakerPaste X,Y pairs for a scatter plot with trendline, equation, r and R². Download PNG.Synthetic Division CalculatorDivide polynomials by x − c (synthetic table) or any polynomial (long division) with steps.Equation SolverSolve any equation for x: exact roots, complex roots, numeric answers, steps and a graph.Inequality CalculatorSolve linear, quadratic, rational and absolute value inequalities with steps and a number line.Inverse Function CalculatorFind the inverse f⁻¹(x) of a function with steps, domain restrictions and a graph.Laplace Transform CalculatorLaplace transform of f(t) with the table rule used for each term and the region of convergence.Limit CalculatorEvaluate limits at a point or at infinity, one-sided or two-sided, with steps, table and graph.Linear Interpolation CalculatorInterpolate or extrapolate y for any x from two points or a data table, with steps and a plot.Matrix Inverse CalculatorFind the inverse of a 2×2 to 8×8 matrix in exact fractions with Gauss–Jordan or adjugate steps.Partial Derivative CalculatorPartial derivatives ∂/∂x, ∂/∂y, second and mixed orders with steps, gradient and Hessian.RREF CalculatorRow reduce any matrix to RREF with exact fractions, every row operation, pivots and rank.Stem and Leaf Plot MakerMake stem-and-leaf plots (standard, split stems or back-to-back) with a key; copy or save PNG.Taylor Series CalculatorTaylor and Maclaurin polynomials of any f(x) to order n, with exact coefficients and a graph.Antilog CalculatorInverse logarithm (antilog) in base 10, e, 2 or any base, with steps and scientific notation.Asymptote CalculatorFind vertical, horizontal and slant asymptotes and holes of a function, with graph and reasoning.Cramer's Rule CalculatorSolve 2x2 and 3x3 linear systems by Cramer's rule with every determinant shown step by step.Dot Plot MakerMake a dot plot or line plot from data or a frequency table; download PNG or SVG.Exponential Regression CalculatorFit y = a·bˣ or y = a·e^(kx) to data with r², predictions, residuals and a plot.Extended Euclidean Algorithm CalculatorFind gcd(a, b) and Bézout coefficients x, y with the full step-by-step division table.Factor Tree GeneratorDraw the prime factor tree of any number as a printable diagram, with exponent form and steps.Function Composition CalculatorFind f(g(x)), g(f(x)), f + g, f · g and f / g with values at a point and domains.X and Y Intercept CalculatorFind the x- and y-intercepts of lines, curves and functions with steps and a graph.Line Intersection CalculatorFind where two lines cross from equations, points or slopes, with parallel checks and a graph.Linear Programming SolverSolve max/min linear programs with the simplex method: tableau steps and a 2-variable graph.Modular Exponentiation CalculatorCompute a^b mod m for huge numbers with square-and-multiply steps (BigInt).Modular Inverse CalculatorFind a⁻¹ mod m with the extended Euclidean algorithm, step by step, for huge numbers too.Nth Term CalculatorFind the nth term formula of a sequence: arithmetic, geometric, quadratic or cubic.Partial Fraction Decomposition CalculatorSplit a rational function into partial fractions with the setup, equations and solution.Perpendicular Line CalculatorEquation of the perpendicular and parallel line through a point, with distance and a graph.Polar Graphing CalculatorGraph polar equations r = f(θ): roses, cardioids, spirals, with a θ range slider and PNG export.Polynomial CalculatorAdd, subtract, multiply, divide and evaluate polynomials; see roots, degree and a graph.Polynomial Long Division CalculatorDivide polynomials with the full long division layout, quotient, remainder and steps.
See all 74 Algebra & Calculus Calculators →