# An Algorithm That Determines Whether An Integer Number Given Is A Prime Number 13th Nov, 2020

A prime number is a natural number greater than one that has no positive divisor other than one and itself.

The following algorithm can be used to determine whether a given integer is a prime number

1       THE ALGORITHM

Step 1: Start

Step 2: Declare variables n, i, flag.

Step 3: Initialize variables

flag1

i2

Step 4: Read n from user.

Step 5: Repeat the steps until i<(n/2)

5.1 If remainder of n÷i equals 0

flag0

Go to step 6

5.2 ii+1

Step 6: If flag=0

Display n is not prime

else

Display n is prime

Step 7: Stop

2        CONVERT THE ALGORITHM INTON PYTHON CODE

```#!/usr/bin/python

num = input('Enter the number which you wish to determine it is prime: ')

if num < 2:

print "\nTh e Number", num, " is not a prime!"

else:

for div in range(2, (num/2)+1):

if num%div==0:

print "\nThe Num ber", num, " is not a prime!"

break

else:

print "\nThe Number", num, " is a prime!"

i9 ```