# Algorithm and Flowchart to find whether a number is Prime Number or Not

[393474 views]

### What is a Prime Number?

A number that's only divisible by 1 and itself is named a Prime Number. For Example, 3, 5, 7, 11 are Prime Numbers.
Note: 2 is the only even prime number.

### Algorithm for Prime Number:

Step 1: Start Step 2: Initialize variables num,flag=1, j=2 Step 3: Read num from user Step 4: If num<=1 // Any number less than 1 is not a prime number Display "num is not a prime number" Goto step 7 Step 5: Repeat the steps until j<[(n/2)+1] 5.1 If remainder of number divide j equals to 0, Set flag=0 Goto step 6 5.2 j=j+1 Step 6: If flag==0, Display num+" is not prime number" Else Display num+" n is prime number" Step 7: Stop

Prime Number program in Python

Javascript Program to Check whether Number is Prime or Not

#### Comments

4 comment
• Danny

To me it looks that there is an error in th flowchart. If a divisor can be found N , it is not a prime, thus...

• Danny

To me it looks that there is an error in the flowchart. If a divisor can be found candidate N , N it is not a prime, thus... when flag is set to ZERO, it is not a prime...

• Umme roshan ara

Thank u sir / mam it is very useful for me thanks a lot

• Satish

Good Explanation

##### Hot Deals ends in

Earn Money While You Sleep. Join Now to avail Exclusive Bonus