Skip to content

Why Most Primes End in 1, 3, 7, or 9

    Most prime numbers end in 1, 3, 7, or 9 because any whole number ending in 0, 2, 4, 5, 6, or 8 is automatically divisible by 2 or 5. The only prime exceptions are 2 and 5 themselves.

    Direct Answer

    Every prime number greater than 5 must end in 1, 3, 7, or 9 when written in base 10. These last digits are not a guarantee of primality. They only show that the number is not immediately divisible by 2 or 5.

    Why Last Digits Matter for Prime Numbers

    A prime number is a whole number greater than 1 with exactly two positive divisors: 1 and itself. If a number has another positive divisor, it is composite.

    In the decimal system, the last digit tells whether a number is divisible by 2 or by 5. Since every even number greater than 2 is composite, and every number ending in 5 greater than 5 is divisible by 5, many last digits are ruled out right away.

    Decimal Last-Digit Rule

    For primes greater than 5, the possible last digits are exactly 1, 3, 7, and 9. These are the decimal digits that are not divisible by 2 or 5.

    Which Ending Digits Are Ruled Out?

    The table below shows why six decimal endings cannot belong to a prime number greater than 5.

    Last digits and whether they can appear at the end of a prime greater than 5.
    Last DigitCan a Prime Greater Than 5 End This Way?Reason
    0NoDivisible by 10, so also divisible by 2 and 5.
    1YesNot automatically divisible by 2 or 5.
    2NoEven numbers greater than 2 are composite.
    3YesNot automatically divisible by 2 or 5.
    4NoEven numbers greater than 2 are composite.
    5NoNumbers ending in 5 are divisible by 5.
    6NoEven numbers greater than 2 are composite.
    7YesNot automatically divisible by 2 or 5.
    8NoEven numbers greater than 2 are composite.
    9YesNot automatically divisible by 2 or 5.

    The Four Possible Endings Are Prime Candidates

    A number ending in 1, 3, 7, or 9 is only a prime candidate. It has passed a quick divisibility filter, but it still may have other factors.

    Can Be Prime

    11, 13, 17, 19, 31, 37, and 41 all end in 1, 3, 7, or 9 and are prime.

    Can Be Composite

    21, 33, 49, 77, 91, and 99 also end in those digits, but each has a divisor other than 1 and itself.

    Common Mistake

    Ending in 1, 3, 7, or 9 does not prove that a number is prime. For example, 91 ends in 1, but 91 = 7 × 13, so it is composite.

    How This Connects to Modular Arithmetic

    The last digit of a decimal number is its remainder when divided by 10. A number ending in 7, for example, has the same remainder as 7 after division by 10.

    Prime Ending Rule in Mod 10

    If p is a prime greater than 5, then p mod 10 is 1, 3, 7, or 9.

    This works because 10 = 2 × 5. Any number with a remainder of 0, 2, 4, 5, 6, or 8 modulo 10 has a direct connection to divisibility by 2 or 5. Those cases cannot produce primes greater than 5.

    Why 2 and 5 Are Exceptions

    The primes 2 and 5 are special because they are the divisors used in the decimal base itself. The number 2 is the only even prime, and 5 is prime because its only positive divisors are 1 and 5.

    After 5, any number ending in 2 is an even number greater than 2, and any number ending in 5 has 5 as a smaller positive divisor. That is why the pattern starts after these two one-digit primes.

    Pattern Note

    The rule depends on writing numbers in base 10. It is a decimal ending pattern, not a claim that prime numbers follow a simple repeating formula.

    Ending Digits Narrow the Search, Not the Proof

    Primality testing needs more than a last-digit check. Trial division, the square root test, and sieving methods look for possible divisors beyond 2 and 5.

    For a number n, the square root test works because every composite number has a factor pair. If one factor is greater than √n, the matching factor must be less than √n. This is why testing possible divisors up to √n is enough for a basic primality check.

    Check a Number Directly

    To test a specific value, use PrimeOrNot’s prime number checker and compare the result with the last-digit rule explained here.

    Test a Prime Candidate

    Enter a whole number and check whether it is prime, composite, or neither.

    Enter a number
    Works for integers up to 15 digits

    Related Concepts

    FAQ

    Do All Primes End in 1, 3, 7, or 9?

    No. The primes 2 and 5 do not end in 1, 3, 7, or 9. Every prime greater than 5 does.

    Is Every Number Ending in 1, 3, 7, or 9 Prime?

    No. These endings only remove numbers that are divisible by 2 or 5. A number ending in 1, 3, 7, or 9 can still be composite, such as 21, 49, 77, or 91.

    Why Can’t a Prime Greater Than 5 End in 5?

    Any whole number greater than 5 that ends in 5 is divisible by 5. Since it has 5 as a smaller positive divisor, it cannot be prime.

    Why Can’t a Prime Greater Than 2 Be Even?

    Every even number greater than 2 is divisible by 2. That gives it a divisor other than 1 and itself, so it is composite.

    Does the Last Digit Pattern Predict Prime Numbers?

    No. It only filters out clear composite cases. A full primality test still needs to check whether the number has other divisors.