Algorithm to find whether a Number is Prime Number or Not

[10020 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

        


Need Programming or any Technical Related Books, Courses or Help Chat with us

Myntra [CPS] IN

Comments



Sponsored Advertisement


Udemy WW



Norton [CPS] WW

Search
Online Games
Play 2048 Game Online and Relax.
Play 2048 Game Online


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