import datetime
start = datetime.datetime.now()
count = 1
for x in range(3,100000, 2):
if x > 10 and x % 10 == 5:
continue
for i in range(3,int(x ** 0.5) + 1, 2):
if x % i == 0:
break
else:
count +=1
# print(x,count)
pass
delta = (datetime.datetime.now() - start).total_seconds()
print(delta)
print(count)
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
start = datetime.datetime.now()
number = 100000
count = 2
for num in range(4,number):
if num%6 !=1 and num%6 !=5:
continue
else:
snum = int(num**0.5+1)
for i in range(5,snum,2):
if not num%i:
break
else:
count +=1
pass
# print(count)
delta = (datetime.datetime.now() - start).total_seconds()
print(delta)
print(count)
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
C:python37python.exe D:/python37/201901/20190109.py
0.173917
9592
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0.168885
9592
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~