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

[476994 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.

Flowchart for Prime Number:

FlowChart for Prime Number Algorithm

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

                 




Health is Wealth? Check Best Medical Insurance for you:-



Comments

5 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

  • dominic emmanuel

    thanks sir/ma this is very helpful for me










Search
Have Technical Doubts????


Hot Deals ends in













Technical Quizzes Specially For You:

Search Tags

    Verify if a number is Prime Number or not Algorithm

    Pseudocode to find whether a Number is Prime Number or Not

    Algorithm for Prime Number Checking

    Check if a number is prime number or not

    prime number algorithm

    Algorithm to check prime number

    prime