**Check a given number is prime or not**

**Prime number:** A number which is divisible by 1 and by itself.

**Note:** 1 is not a prime number. Prime number starts with ‘2’

**Algorithm:**

#1 Get the input number

#2 Initialize the loop variable by 2 and continue till the square root of the number

#3 If the input number is exactly divisible by loop variable then its not a prime number, hence break the loop

#4 Else the given number is prime

Advertisements