Python program to Detect Prime Numbers

import math
x = int(input("Insert any number to check: "))
if x<2:
 print("Please, insert number greater than or equal to 2")
elif x == 2:
 print("This is a prime number!")
y = 2
num = int(math.sqrt(x))
while y <= num:
 if x%y == 0:
  print("This is NOT a prime number")
 y += 1
print("This is a prime number")




Insert any number to check: 123
This is NOT a prime number


Insert any number to check: 11
This is a prime number

Subscribe For Daily Updates

100+ Python Pattern Examplespython pattern examples - star patterns, number patterns