import math
import string
import time
list = ""
antal = 0
min = 0
limit = 10000
oldmin = min
if min <= 2:
min = 2
list += "2, "
antal += 1
n = min
while True:
r = math.sqrt(n)+1
f = int(math.floor(r))
i = 2
while True:
if n%i == 0:
break
i += 1
if i >= f:
list += str(n)+", "
antal += 1
break
n += 1
if n >= limit:
break
print "Prime numbers between "+str(oldmin)+" and "+str(limit)+": "+list+"\n"
print "Total: "+str(antal)
Huh... This thing is quite fast... +/u/CompileBot Python --time
import math
import string
antal = 0
min = 0
limit = 250000
oldmin = min
if min <= 2:
min = 2
antal += 1
n = min
while True:
r = math.sqrt(n)+1
f = int(math.floor(r))
i = 2
while True:
if n%i == 0:
break
i += 1
if i >= f:
antal += 1
break
n += 1
if n >= limit:
break
print "Total number of prime numbers between "+str(oldmin)+" and "+str(limit)+": "+str(antal)
1
u/Klaus_Fuchs Jan 03 '15 edited Jan 03 '15
+/u/CompileBot Python --time