A Program to Check Prime Number
In this example, we are giving a program to check whether an integer is a prime number or not.
Program to check prime number:
# Check whether an integer is a prime number or not
num = int(input('Enter a number: '))
if num > 1 :
for i in range(2,num):
if (num % i) == 0:
print(num,"is not a prime number")
print(i,"times",num//i,"is",num)
break
else:
print(num,"is a prime number")
else:
print(num,"is not a prime number")
Output:
Enter a number: 442 442 is not a prime number 2 times 221 is 442