Skip to content

Instantly share code, notes, and snippets.

@Ventsislav-Yordanov
Last active January 27, 2018 04:23
Show Gist options
  • Save Ventsislav-Yordanov/dc67455197497e3e6eacf336058c22be to your computer and use it in GitHub Desktop.
Save Ventsislav-Yordanov/dc67455197497e3e6eacf336058c22be to your computer and use it in GitHub Desktop.
Function that checks if the passed number is prime or not
def is_prime(n):
if n <= 1:
return False
elif n <= 3:
return True
elif n % 2 == 0 or n % 3 == 0:
return False
current_number = 5
while current_number * current_number <= n:
if n % current_number == 0 or n % (current_number + 2) == 0:
return False
current_number = current_number + 6
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment