10001th prime: Difference between revisions

Content added Content deleted
Line 532: Line 532:


=={{header|Python}}==
=={{header|Python}}==
<lang python>import time; max=10001; n=1; p=1; # PRIMES russian DANILIN
<lang python>import time; max=10001; n=1; p=1; # PRIME_numb.py russian DANILIN
while n<=max: # 10001 104743 5 seconds
while n<=max: # 78081 994271 45 seconds
f=0; j=2 # rextester.com/AHEH3087
f=0; j=2; s = int(p**0.5) # rextester.com/AAOHQ6342
while f < 1:
while f < 1:
if j >= int(p**0.5):
if j >= s:
f=2
f=2
if p % j == 0:
if p % j == 0:
Line 543: Line 543:
if f != 1:
if f != 1:
n+=1;
n+=1;
#print(n,p);
#print(n,p);
p+=2
p+=1
print(n-1,p-2)
print(n-1,p-1)
print(time.perf_counter())</lang>
print(time.perf_counter())</lang>
{{out}}
{{out}}