10001th prime: Difference between revisions

m
→‎{{header|C#|CSharp}}: not sure why "@ Tio.run" was removed, added "trial division" mention.
m (→‎{{header|C#|CSharp}}: not sure why "@ Tio.run" was removed, added "trial division" mention.)
Line 201:
 
=={{header|C#|CSharp}}==
Comparing performance of the one-at-a-time trial division method vs the sieve of Eratosthenes method. About ten times faster for the sieve. It may appear that the sieve may be off by one, <code>pr[10000]</code> but since the array is zero based, it's the 10001st value.
<lang csharp>using System; class Program {
 
Line 214:
 
static void Main(string[] args) {
Console.WriteLine("One-at-a-time trial division vs sieve of Eratosthenes");
var sw = System.Diagnostics.Stopwatch.StartNew();
var t = prime(10001); sw.Stop(); double e1, e2;
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 trial division vs sieve of Eratosthenes
104,743 3.8943 ms 104,743 357.9 μs 10.881 times faster</pre>
 
 
 
 
 
=={{header|C#|CSharp}}==