You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

27 lines
436 B

#!/usr/bin/env python
# Python version of a Prime Number Finder
# haplo@mindstab.net
import sys
import math
try: max = int(sys.argv[1]);
except:
print "primes.py <MAX NUM>"
sys.exit()
if max < 1:
print "Invalide MAX NUM"
sys.exit()
for cnt in range(3, max, 2) :
testMax = math.sqrt(cnt)+1
isPrime = 1
for test in range(3, int(testMax), 2):
isPrime = cnt % test
if isPrime == 0:
break
if isPrime != 0 :
print cnt