Skip to content

Instantly share code, notes, and snippets.

@zhangys-lucky
Created August 19, 2015 00:43
Show Gist options
  • Save zhangys-lucky/2ebc91615609184aae59 to your computer and use it in GitHub Desktop.
Save zhangys-lucky/2ebc91615609184aae59 to your computer and use it in GitHub Desktop.
check prime
#! /usr/bin/python
from sys import argv
from math import sqrt
def is_prime(num):
s = sqrt(num)
step = 4
if num <= 3:
return True
if num % 2 == 0 or num % 3 == 0:
return False
i = 5
while i <= s:
if num % i == 0:
break
step ^= 6
i += step
return i > s
a = int(argv[1])
print(is_prime(a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment