In this code we will see how to find the prime number using python.

prime number (or a prime ) is a natural number greater than 1 that is not a product of two smaller natural numbers.

For Example if the number is 5

5%1 = 0 ; // 5 is divisible by 1.
5%2 = 1 ; // 5 is not divisible by 2.
5%3 = 2 ; // 5 is not divisible by 3.
5%4 = 1 ; // 5 is not divisible by 4.
5%5 = 0 ; // 5 is divisible by 5.

That means 5 is only divisible by 1 and 5 , So according to the definition we can say 5 is a prime number.

2, 7, 11, 13, 17 these are also prime number.

Open terminal and run:

$ python prime.py
enter a number : 5

Sample input:

$ python prime.py 
enter a number :5

Sample Output:

5 is a prime number

if you have any better idea or suggestion, please let me know in the comment below, I hope this may help you.