Skip to content

Instantly share code, notes, and snippets.

@sooop
Created May 10, 2018
Embed
What would you like to do?
소수 판별함수
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