How to Find Prime Numbers?

Last Updated : 14 Jul, 2026

Prime numbers are those numbers that have only two factors: 1 and the number itself. In other words, a prime number is a number that is exactly divisible by 1 and itself. 

  • A prime number should contain exactly two factors.
  • A prime number is divisible by 1 and the number itself.

Methods to Find Prime Numbers

Below are some methods to check whether a number is prime or not:

1. Even numbers are not prime [except 2]

All even numbers are NOT prime, except for 2. This means if a number ends with 0, 2, 4, 6, or 8, it is not prime.

2. Divisibility Rules for Small Primes

For checking small prime numbers, we can use these divisibility rules:

Divisibility by 3 - If the sum of digits is divisible by 3, then the number can never be prime.

Divisibility by 5 - If a number ends with 0 or 5, it is not prime.

Divisibility by 7 - Double the last digit of a given number, then subtract it from the rest of the digits, and check if the result is divisible by 7.
Example: N = 203. Double the last digit [3x2 = 6], then subtract 6 from 20 [remaining two digits]. 20-6 = 14, which is divisible by 7. So, 203 is not prime.

3. Division Method

One simple method is to divide numbers by all integers from 2 up to the square root of a given number.

Example—

Number = 29

Find square root of 29, which is 5.39. Now, we need to divide 29 by each whole number which is 2 to 5.

29 ÷ 2 = not a whole number,
29 ÷ 3 = not a whole number,
29 ÷ 4 = not a whole number,
29 ÷ 5 = not a whole number.

We can see non of these results are in whole number. So, 29 is a Prime Number.

This method is not suitable for very small primes [like 2, 3, 5, 7, etc.]. It is better to use divisibility rules for such small numbers. Also, this method doesn't work well for large numbers [say, 100003] since the square root of a large number itself might be a large number [316 in this case]. You might need to check the divisibility of those many numbers.

4. Trial Division Method

The trial division method checks for primes by dividing the numbers by all possible divisors to check if any divisor evenly divides without a remainder. This method is very similar to the above-discussed method. The divisor method checks only up to the square root of the number, but the trial division method continues dividing by all integers up to the number itself [except 1 and the number itself].

Example—

Number = 17

Divide 17 by 2 -> doesn’t divide evenly (not divisible by 2).
Divide 17 by 3 -> doesn’t divide evenly.

--> We can skip checking for all even numbers. Since it is not divisible by 2, it can’t be divisible by any higher even numbers.

Divide 17 by 5 -> doesn’t divide evenly.

We can continue checking with all odd numbers till 15 [7, 9, 11, etc.]. Since none of these divide 17 evenly, it's clear that 17 is prime.

This method is time consuming as well for large numbers. If N is 100000, then you will have to check all divisors up to N-1. Hence, this method is useful for a small number only.

5. Factorization Method

In this method, we break down the numbers into prime factors. If the number has a product of two smaller numbers (other than 1 and itself), then it is composite. Otherwise, it is Prime.

Examples—

Number = 17

Divide 17 by 2 -> Not divisible, leaves a remainder
Divide 17 by 3 -> Not divisible, leaves a remainder
Divide 17 by 5 -> Not divisible, leaves a remainder
We can keep on checking. There is no smaller number which divide 17 evenly. So, 17 is Prime.

Number = 35

Divide 35 by 2 -> Not divisible, leaves a remainder
Divide 35 by 3 -> Not divisible, leaves a remainder
Divide 35 by 3 -> Not divisible, leaves a remainder
Divide 35 by 7 -> It's divisible evenly. 5 x 7. So, 35 is Not Prime.

6. Prime Numbers in the Form 6n ± 1

Any prime number (greater than 3) can be written in the form of 6n + 1 or 6n - 1, where n is a whole number.

For example:

  • The number 19 can be written as 6(3) + 1 = 19, making it a prime number.
  • The number 23 can be expressed as 6(4) - 1 = 23, confirming it is also prime.

Exceptions:

This rule helps identify possible prime numbers, but not all numbers of the form 6n+1 or 6n−1 are prime, so further checking is needed.

25 = 6(4) + 1 is not prime (it is 52).
35 = 6(6) - 1 is not prime (it is 5 × 7).

7. For prime numbers greater than 40

To know the prime numbers greater than 40, this formula can be used: n2 + n + 41, where n = 0, 1, 2, ….., 39
For example:
(0)2 + 0 + 0 = 41
(1)2 + 1 + 41 = 43
(2)2 + 2 + 41 = 47

Note -

For n>39, this formula can give composite numbers which is non-prime. So, we need to further verify to confirm if the result is correct or not.
Example - (41)2 + 41 + 41 = 1763. It is divisible by 41 and 43, so 1763 is not Prime.

Let's see some advanced methods that work faster for checking prime numbers.

Fastest Way to Find a Prime Number: AKS Primality Test

The AKS primality test is one of the fastest deterministic methods for determining if a number is prime.

  • It checks whether a number is prime by using polynomial congruence and works for all integers.
  • The algorithm has a running time of approximately O((log n)6), which makes it efficient even for large numbers.
  • Unlike other primality tests that may only work for specific cases or rely on randomness, the AKS test guarantees an answer in a finite and predictable time.

Examples on How to Find Prime Numbers

Q1. Is 51 a prime number? 

No, because the only factors 51 are 1, 3, 17, and 51. According to the definition, a prime number should contain only two factors. Factors of 51 = 1, 3, 17, 51 ( 4 Factors ). So, 51 is not a prime number.

Q2. Is 1 a prime number? 

1 is not a prime number because according to the definition, a prime number should exactly two factors But, number 1 has one and only one factor which is 1 itself. Thus, 1 is not considered a Prime number. Factors of 1 = 1 ( 1 Factor). So, 1 is not a prime number 

Q3. Is 11 a prime number?

Yes, 11 is a prime number because it is only divisible by 2 numbers that is 1 and the number itself (11). Its has two factors 1 and 11 only. Factors of 11 = 1, 11 ( 2 Factors ). So, 11 is a prime number.

Q4. Find all the prime numbers from the following numbers: 1, 22, 3, 51, 75, 88, 65, 63, 19, 7, 39, 47, 60, 100, 12, 10, 5.

All the prime number from the given numbers are - 3, 19, 7, 39, 47, 5

Explanation,

  • Factor of 1 are = 1
  • Factor of 22 are = 1, 2, 11, 22
  • Factor of 3 are = 1, 3  ( only two factors )
  • Factor of 51 are = 1, 3, 17, 51
  • Factor of 75 are = 1, 3, 5, 15, 25, 75.
  • Factor of 88 are = 1, 2, 4, 8, 11, 22, 44, 88
  • Factor of 65 are = 1, 5, 13, 65
  • Factor of 63 are = 1, 3, 7, 9 , 21, 63
  • Factor of 19 are = 1, 19  ( only two factors )
  • Factor of 7 are = 1, 7  ( only two factors )
  • Factor of 39 are = 1, 3, 13, 39  
  • Factor of 47 are = 1, 47  ( only two factors )
  • Factor of 60 are = 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60
  • Factor of 100 are = 1, 2, 4, 5,10, 20, 25, 50, 100
  • Factor of 12 are = 1, 2, 3, 4, 6, 12
  • Factor of 10 are = 1, 2, 5, 10
  • Factor of 5 are = 1, 5  ( only two factors )

Q5. Which is the smallest prime number in the number system?

2 is the smallest prime number in the number system. It has only two factors that is 1 and 2. Factors of 2 are : 1, 2

Q6. What are the largest 2-digit prime numbers?

97 is the largest two digit prime numbers. Factors of 97 are = 1, 97 

Comment

Explore