How to check whether a number is a prime number or not?


Procedure to check whether a number is prime or not:

To check whether a number 'x' is prime or not, find the square numbers in which x lies and let us x lies between a and b then check if x is divisible by prime numbers up to square root b.

For example, 

Let's take 37.

  • To check whether 37 is a prime, we have to find between which square numbers 37 lies.
  • 37 lies between 36(square of 6) and 49(square of 7).
  • We have to check if 37 is divisible by prime numbers less than 7.
  • 37 is not divisible by 2 or 3 or 5 or 7.
  • Therefore, 37 is a prime number.  

Tutorialspoint
Tutorialspoint

Simply Easy Learning

Updated on: 10-Oct-2022

438 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements