import time
y=3
start=time.time()
myfile=open('primes.txt','w')
while y<40000:
x=2
limit=y**0.5
while x<=limit:
if y%x==0:break
x+=1
else:
print >>myfile,y,
y+=2
myfile.close()
end=time.time()
print "End!\nUse Time:%f s" % (end-start)