Created
December 3, 2015 14:41
-
-
Save MasazI/d843419c306a9d784944 to your computer and use it in GitHub Desktop.
hi-performance python cp1
This file contains hidden or 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
import math | |
import sys | |
def check_prime(number): | |
sqrt_number = math.sqrt(number) | |
number_float = float(number) | |
for i in xrange(2, int(sqrt_number)+1): | |
if (number_float / i).is_integer(): | |
return False | |
return True | |
if __name__ == '__main__': | |
argvs = sys.argv | |
argc = len(argvs) | |
if(argc != 2): | |
print 'Usage: python %s num' % argvs[0] | |
quit() | |
num = argvs[1] | |
print "check_prime: " + num + "=", check_prime(int(num)) | |
print "check_prime: " + num + "+19=", check_prime(int(num)+19) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment