Infinite sequence of prime numbers that uses wheel factorization.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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