**Write a program to check if a number entered by the user is a prime number.**

```
#Prime number check
#Function to check if a number entered by the user is a Prime number
#A prime number is one that is divisible only by 1 and itself.
# 5, 11, 29 are prime numbers but 6, 45, 216 are not prime numbers
def IsPrime(n):
flag = 0
for i in range(2, n):
if (n % i) == 0:
flag = 1
break
#End of if stmt
# End of for loop
if flag == 1:
return False
else:
return True
# End of function
n = int(input("Pls enter a number "))
if IsPrime(n):
print (n, " is a Prime number")
else:
print (n, " is not a Prime number")
#End of if stmt
#EO Program
```

Advertisements