25 - Write a program in Python to input a number and determine whether the number is a prime number or not.
n=int(input("Enter the number: "))
for i in range(2,n+1):
if (n%i==0):
break
if(n==i):
print(n,"is a prime number")
else:
print(n,"is not a prime number")
Output:
Enter the number: 29
29 is a prime number
Enter the number: 37
37 is a prime number
Enter the number: 35
35 is not a prime number
No comments:
Post a Comment