Write a program that prompts the user to input a positive integer. It should then output a
a message indicating whether the number is a prime number.
(Note: An even number is prime if it is 2. An odd integer is prime if it is not divisible by any odd
integer less than or equal to the square root of the number.)

Respuesta :

num = -1

count = 0

while num < 0:

   num = int(input("Enter a positive number: "))

if num % 2 == 0:

   if num == 2:

       print(str(num)+" is a prime number")

   else:

       print(str(num)+" is not a prime number")

else:

   for x in range(1, int(num**0.5)+1,2):

       if num % x == 0:

           count += 1

   if count > 1:

       print(str(num)+" is not a prime number")

   else:

       print(str(num)+" is a prime number")

I hope this helps!

ACCESS MORE