Algorithm to find whether a Number is Prime Number or Not


What is Prime Number?

Prime Number is a number which is only divisible by itself and 1. For Example, 3,5,7 are Prime Numbers.
Note: 2 is the only even prime number.

Algorithm for Checking Prime Number:

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

FlowChart for Prime Number Checking Algorithm:

FlowChart for Prime Number Algorithm

For Prime Number Program in Python, visit here: Prime Number program in Python

For Prime Number Program in Javascript, visit here: Javascript Program to Check whether Number is Prime or Not


Solution Didn't Worked 1 DownvotesDownvote


Get Programming Help

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