Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Infinite sequence of prime numbers that uses wheel factorization.
public class WheelPrimeSequence : IEnumerable<int>
{
public IEnumerator<int> GetEnumerator()
{
yield return 2;
yield return 3;
yield return 5;
var e = new WheelPrimeEnumerator();
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