Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@sooop
Created May 10, 2018 03:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sooop/161787bebc08841fc97604b20f7f7fdb to your computer and use it in GitHub Desktop.
Save sooop/161787bebc08841fc97604b20f7f7fdb to your computer and use it in GitHub Desktop.
소수 판별함수
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