Last active
March 17, 2019 09:01
-
-
Save pysoftware/c98f092b47675c626e1c6be657467039 to your computer and use it in GitHub Desktop.
IS PRIME
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""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