10001th prime: Difference between revisions
Content added Content deleted
Line 528: | Line 528: | ||
=={{header|Python}}== |
=={{header|Python}}== |
||
<lang python>import time; max=10001; n= |
<lang python>import time; max=10001; n=1; p=1; # PRIMES.py |
||
while n<=max: # 10001 104743 |
while n<=max: # 1.5 5 seconds 10001 104743 |
||
f=0; j=2 # rextester.com/IYLSI54964 |
|||
⚫ | |||
while n <= max: |
|||
f=0; j=2 |
|||
while f < 1: |
|||
if |
if j >= int(p**0.5): |
||
f=2 |
|||
if p % j == 0: |
|||
⚫ | |||
f=1 |
|||
⚫ | |||
⚫ | |||
if f != 1: |
|||
n+=1; #print(n,p) |
|||
⚫ | |||
⚫ | |||
print(time.perf_counter())</lang> |
print(time.perf_counter())</lang> |
||
{{out}} |
{{out}} |
||
<pre>10001 104743 7 seconds</pre> |
<pre>10001 104743 7 seconds</pre> |
||
=={{header|QB64}}== |
=={{header|QB64}}== |