How-to Guide 5 min read

How to Check If a Number Is Prime (and Find Its Prime Factors)

Check if a number is prime by testing divisors up to its square root. Worked examples for 91, 97 and 221, prime factorisation and quick divisibility rules.

how to check if a number is primeis 91 a prime numberprime factorizationprime numbers 1 to 100prime number checker

The short answer

To check if a number is prime, divide it by each prime number up to its square root. If none of them divides it exactly, it is prime; if one does, it is not. For example, √97 is about 9.8, so you only test 2, 3, 5 and 7. None divides 97, so 97 is prime. But 91 ÷ 7 = 13, so 91 is not prime. The free Prime Number Checker does this instantly and, for non-primes, shows the full prime factorisation.

What counts as a prime number

A prime number is a whole number greater than 1 with exactly two divisors: 1 and itself.

  • 2, 3, 5, 7, 11 and 13 are prime.
  • 4 (= 2 × 2), 9 (= 3 × 3) and 15 (= 3 × 5) are composite.
  • 1 is neither prime nor composite, because it has only one divisor.
  • 2 is the only even prime. Every other even number is divisible by 2.

The square root method, step by step

  • Find the square root of the number and round it down. For 221, √221 is about 14.9, so the limit is 14.
  • List the primes up to that limit: 2, 3, 5, 7, 11, 13.
  • Divide by each one in turn. Stop as soon as one divides exactly.
  • If none divides exactly, the number is prime.
  • For 221: not even, digit sum 5 (not divisible by 3), doesn't end in 0 or 5, 221 ÷ 7 = 31.57, 221 ÷ 11 = 20.09, 221 ÷ 13 = 17 exactly. So 221 = 13 × 17 and is not prime.

    Why the square root is enough: factors come in pairs that multiply to the number. If one factor is bigger than the square root, the other must be smaller, so it would already have turned up.

    Worked examples

    NumberSquare root (about)Primes to testResult
    517.12, 3, 5, 751 = 3 × 17, not prime
    919.52, 3, 5, 791 = 7 × 13, not prime
    979.82, 3, 5, 7Prime
    22114.9up to 13221 = 13 × 17, not prime
    202645.02 first2026 = 2 × 1013, not prime
    202745.0up to 43Prime
    863392.9up to 898633 = 89 × 97, not prime

    Numbers like 51, 57 (3 × 19), 87 (3 × 29) and 91 are classic traps because they "look" prime. A quick digit-sum check catches the multiples of 3.

    Quick divisibility rules

    These rules let you skip long division for the smallest primes:

    Divisible byRuleExample
    2Last digit is even1,358
    3Digit sum is divisible by 357: 5 + 7 = 12
    5Ends in 0 or 52,345
    7Double the last digit and subtract it from the rest; the result is divisible by 791: 9 − 2 = 7
    11Alternating sum of digits is divisible by 111,001: 1 − 0 + 0 − 1 = 0

    Prime factorisation

    Every whole number above 1 can be written as a product of primes in exactly one way (apart from order). To find it, keep dividing by the smallest prime that works:

    360

    • 360 ÷ 2 = 180
    • 180 ÷ 2 = 90
    • 90 ÷ 2 = 45
    • 45 ÷ 3 = 15
    • 15 ÷ 3 = 5
    • 5 is prime

    So 360 = 2³ × 3² × 5. The checker writes this as 2^3 × 3^2 × 5.

    More examples: 1,001 = 7 × 11 × 13; 561 = 3 × 11 × 17; 999,999 = 3³ × 7 × 11 × 13 × 37; 1,234,567 = 127 × 9,721.

    Prime factorisation is the quickest route to HCF and LCM, and to simplifying fractions. See how to find HCF and LCM for the next step.

    How to use the Prime Number Checker

    The tool has two tabs.

    Prime Checker

  • Type a positive whole number. Decimals are cut to the whole number in front of the point, so 12.7 is checked as 12.
  • The result appears immediately: a green tick if it is prime, a red cross if not.
  • For composite numbers it shows the prime factorisation, such as 360 = 2^3 × 3^2 × 5.
  • Quick buttons load 2, 17, 97, 127, 997 and 7919, all of which are prime.
  • List Primes

  • Drag the slider to choose a limit from 10 to 1,000 (in steps of 10).
  • The tool shows how many primes there are up to that limit and lists them all.
  • There are 25 primes up to 100 and 168 up to 1,000.

    A limit on very large numbers: the checker uses ordinary JavaScript numbers, which are exact only up to 9,007,199,254,740,991. Beyond that, digits get rounded, so results for numbers with 16 or more digits may not be reliable.

    The primes up to 100

    2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97.

    Common mistakes

    • Calling 1 prime. It isn't, by definition.
    • Calling every odd number prime. 9, 15, 21, 27, 33, 35, 39, 45, 49, 51, 57 and so on are odd but composite.
    • Testing past the square root. It wastes time without changing the answer.
    • Testing non-prime divisors. If a number isn't divisible by 2, it can't be divisible by 4, 6 or 8, so test primes only.
    • Forgetting repeated factors. 360 has three 2s; keep dividing by the same prime until it no longer fits.

    Related tools

    Use the GCD and LCM Calculator once you have prime factors, and the Fraction Calculator to simplify fractions. For powers, roots and logarithms, the Scientific Calculator has the functions you need.

    Frequently asked questions

    How do you check if a number is prime?

    Try dividing it by every prime up to its square root. If none divides it exactly, the number is prime. For 97, the square root is about 9.8, and 2, 3, 5 and 7 all leave a remainder, so 97 is prime.

    Is 1 a prime number?

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

    Is 91 a prime number?

    No. 91 = 7 × 13. It looks prime because it is odd, is not a multiple of 3 or 5 and does not end in 5, which is why it is a common trick question.

    How many prime numbers are there between 1 and 100?

    25. Between 1 and 1,000 there are 168. The List Primes tab of the Prime Number Checker shows them.

    Why do I only need to check up to the square root?

    If a number has a factor larger than its square root, the matching factor must be smaller than the square root, so you would already have found it.

    Try this tool on Lazyblink

    Put this guide into practice with our free online tool — no signup required.

    Open tool