Created
May 10, 2018 03:14
-
-
Save sooop/161787bebc08841fc97604b20f7f7fdb to your computer and use it in GitHub Desktop.
소수 판별함수
This file contains 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
def is_prime(n: int) -> bool: | |
if n < 2: return False | |
if n < 4: return True | |
if n % 2 == 0 or n % 3 == 0: | |
return False | |
if n < 9: return True | |
k, l = 5, n ** 0.5 | |
while k <= l: | |
if n % k == 0 or n % (k+2) == 0: | |
return False | |
k += 6 | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment