58. Python Program to find the given number is Prime number or Not.
How does this program work?
- In this program you are going to learn about to check if a number is Prime number or not using Python.
- Prime number means which is only divisible by 1 and that number itself, and cannot divisible by any other number.
- When the number is divided by 2, we use the remainder operator % to compute the remainder then flag will be effected.
- If the flag is zeo, the number is prime number else the number is not a prime.
Here is the code
a = int(input("Enter a number: "))
if a > 1:
for i in range(2,a):
if (a % i) == 0:
print(a,"is not a prime number")
break ;
else:
print(a,"is a prime number")
else:
print(a,"is not a prime number")