python program to check if number is prime or not code example
Example: how to check if a number is prime in python
import math
def prime(x):
if x == 2 or x == 3 or x==5:
return True
if x == 1 or x == 4:
return False
num = 2
a= math.sqrt(x)+4
while a > num:
if x % num == 0:
return False
else:
num = num + 1
return True