Program to check if a number is prime

# Prime Number Check
num = int(input("Enter a number: "))

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")
Output:
Enter a number: 29
29 is a prime number

Leave a Reply

Your email address will not be published. Required fields are marked *