Skip to content

Instantly share code, notes, and snippets.

@pysoftware
Last active March 17, 2019 09:01
Show Gist options
  • Save pysoftware/c98f092b47675c626e1c6be657467039 to your computer and use it in GitHub Desktop.
Save pysoftware/c98f092b47675c626e1c6be657467039 to your computer and use it in GitHub Desktop.
IS PRIME
"""IS PRIME"""
'''O(n)'''
def isPrime(n):
d = 2
while n % d != 0:
d += 1
return d == n
print(isPrime(int(input())))
"""O(n^0.5)"""
def isPrime2(n):
d = 2
while d * d <= n and n % d != 0:
d += 1
return d * d > n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment