The sieve of Sundaram: Difference between revisions

Content added Content deleted
(Added C# version)
m (→‎{{header|C#|CSharp}}: added note about conventionalization)
Line 119: Line 119:
public static IEnumerable<int> Sundaram(int n)
public static IEnumerable<int> Sundaram(int n)
{
{
// yield return 2;
int k = (n + 1) >> 1, v = 1;
int k = (n + 1) >> 1, v = 1;
var comps = new bool[k + 1];
var comps = new bool[k + 1];
Line 150: Line 151:


The millionth odd prime number: 15485867
The millionth odd prime number: 15485867
184.3825 ms</pre>P.S. for those (possibly faithless) who wish to have a conventional prime number generator, one can uncomment the <code>yield return 2</code> line at the top of the function.
184.3825 ms</pre>


=={{header|F_Sharp|F#}}==
=={{header|F_Sharp|F#}}==