Python program to check whether the given number is Prime or not

 To check whether  the given number is prime or not , we have to implement following  Python program.

In this program the user will give the input as an integers value to detect whether the given number is Prime or not.

What is prime number ?

A prime number is a natural number which is always greater than 1 and has no any positive divisors other than 1 and itself. some of the examples of prime number are { 2 , 3, 5, 7, etc.}


Let's implement the code :-


num = int(input("Enter the number:\n"))
Prime = True
for i in range (2, num):
   if (num % i == 0):
      Prime = False
if Prime:
      print ("The given number is a prime number")
else:
      print ("The given number is not a prime number")
     


OUTPUT

Enter the number:

16

The given number is not a prime number


Enter the number:

13

The given number is a prime number


If you have any queries or suggestions, please feel free to ask. Thank You!

No comments:

If you have any doubts please let's me know

Powered by Blogger.