Elle Joy Vasquez
Preliminary Test 01
Create a Python function that takes a number as a parameter and check the number is PRIME or NOT.
Note: A prime number (or a prime) is a natural number greater than 1 and that has no positive divisors other than 1 and itself.
def prime(num):
if num > 1:
for i in range(2, int(num/2)+1):
if (num % i) == 0:
print(num, "is not a prime number")
break
else:
print(num, "is a prime number")
else:
print(num, "is not a prime number")
number = int(input("Enter number: "))
prime(number)
Comments
Leave a comment