python例程之质数
#!/usr/bin/python
#find primes
#usage: ./findprimes.py MAX
import sys
def findprimes(max):
'''list find prime(int max)
'''
primes = [2]
for i in range(3,max):
for j in range(2,i):
#x = raw_input('\n')
if i%j == 0:
break
elif j+1 == i:
primes.append(i)
return primes
if __name__ == '__main__':
MAX = int(sys.argv[1])
print 'the 1 to %d primes:' %MAX
print findprimes(MAX)
python例程之质数