In this post we shall learn about finding **prime number** program in **python**.If a number is only divisible by 1 and itself then that number is called as **prime number.**Otherwise it is not a prime number.

The following program is for finding prime number

n = int(input("\n Enter number to find whether it is prime or not:")) flag = 0 i = 0 for i in range(2,n-1) : if((n%i) == 0) : flag = flag +1 break if(flag == 0) : print("\n\t\tGiven number " + str(n)+" is a prime number"); else : print("\n\t\tGiven number " + str(n) +" is not a prime number" );

# Download the Source Code

Advertisements