Jump to content

10001th prime: Difference between revisions

(Implementation in R via the 'primes' package)
Line 230:
Console.Write(" {0:n0} {1} μs {2:0.000} times faster", t,
(e2 = sw.Elapsed.TotalMilliseconds) * 1000.0, e1 / e2); } }</lang>
{{out|Output @ Tio.run}}
<pre>One-at-a-time vs sieve of Eratosthenes
104,743 3.8943 ms 104,743 357.9 μs 10.881 times faster</pre>
 
 
 
 
 
=={{header|C#|CSharp}}==
<lang csharp>using System; using System.Text; // PRIMES russian DANILIN
namespace p10001 // 10001 104743
{ class Program
{ static void Main(string[] args)
{ int max=10001; int n=0; int s=1; int j;
while (n<=max)
{ int f=0;
for (j=2; j<Convert.ToInt32(Math.Pow(s,0.5)+1); j++)
{ if (s % j == 0) { f=1; } }
if (f == 0) { n++; }
s++;
}
Console.Write("{0} {1}", n-1,s-1);
Console.ReadKey();
}}}</lang>
{{out}}
<pre>104743</pre>
 
=={{header|C++}}==
51

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.