Skip to content

Instantly share code, notes, and snippets.

@flamanta
Last active May 20, 2019 07:49
Show Gist options
  • Save flamanta/08a8b7bcad3a8d0bd9cb1e37ee32574a to your computer and use it in GitHub Desktop.
Save flamanta/08a8b7bcad3a8d0bd9cb1e37ee32574a to your computer and use it in GitHub Desktop.
[Check if prime] #math
def is_prime(n):
if n < 2:
return False
if n == 2:
return True
for num in range(3, int(n**0.5)+1, 2):
if n % num == 0:
return False
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment