Skip to content

Instantly share code, notes, and snippets.

@igorvanloo
Created July 21, 2021 13:33
Show Gist options
  • Save igorvanloo/dc432178ec19d12f84c08180df3a3fe9 to your computer and use it in GitHub Desktop.
Save igorvanloo/dc432178ec19d12f84c08180df3a3fe9 to your computer and use it in GitHub Desktop.
Is prime Function
def is_prime(x):
if x <= 1:
return False
elif x <= 3:
return True
elif x % 2 == 0:
return False
else:
for i in range(3, int(math.sqrt(x)) + 1, 2):
if x % i == 0:
return False
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment