C#: How to make Sieve of Atkin incremental
I don't know if this is possible or not, but I just gotta ask. My mathematical and algorithmic skills are kind of failing me here :P The thing is I now have this class that generates prime numbers up to a certain limit: public class Atkin : IEnumerable<ulong> { private readonly List<ulong> primes; private readonly ulong limit; public Atkin(ulong limit) { this.limit = limit; primes = new List<ulong>(); } private void FindPrimes() { var isPrime = new bool[limit + 1]; var sqrt = Math.Sqrt(limit); for (ulong x = 1; x <= sqrt; x++) for (ulong y = 1; y <= sqrt; y++) { var n = 4*x*x + y*y; if (n <=