python求素数问题
本帖最后由 janelml 于 2013-03-21 14:32:30 编辑 先看我的代码
import math,sys
number = raw_input("input the number:")
number = int(number)
if(number<=1):
print 'number <=1'
sys.exit()
for i in range(2,int(math.sqrt(number)) + 1):
if(number%i==0):
print 'number %i is not prime number' %(number)
sys.exit()
print 'number %i is the prime number' %(number)