Skip to content

Instantly share code, notes, and snippets.

@einarwh
Created October 5, 2011 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save einarwh/1263277 to your computer and use it in GitHub Desktop.
Save einarwh/1263277 to your computer and use it in GitHub Desktop.
A slightly optimized prime sequence.
public class PrimeSequence : IEnumerable<int>
{
public IEnumerator<int> GetEnumerator()
{
yield return 2;
var e = new OddPrimeEnumerator();
while (e.MoveNext())
{
yield return e.Current;
}
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment