Develop a Python program to print the message that the number is prime or not. Note: - not need to check for 1 ask the user to enter the value greater than 10
Develop a Python
Note: - not need to check for 1 ask the user to enter the value greater than 10
Below is the required python program: -
Program: -
#Ask the user to enter the number
num = int(input("Please enter the number to check: "))
#if the number is greater than 1
if num > 1:
#Use the loop to iterate
#and check for factors
for i in range(2,num):
#if the remainder is zero
if (num % i) == 0:
#Display the message
print(num,"is not a prime number")
#break from loop
break
else: #display the error message
print(num,"is a prime number")
#Display the error message
else:
print("Run the program again and enter the number greater than 1")
Step by step
Solved in 2 steps with 1 images