Sieve theory is a set of general techniques in number theory, designed to count, or more realistically to estimate the size of, sifted sets of integers. The prototypical example of a sifted set is the set of prime numbers up to some prescribed limit X. Correspondingly, the prototypical example of a sieve is the sieve of Eratosthenes, or the more general Legendre sieve. The direct attack on prime numbers using these methods soon reaches apparently insuperable obstacles, in the way of the accumulation of error terms. In one of the major strands of number theory in the twentieth century, ways were found of avoiding some of the difficulties of a frontal attack with a naive idea of what sieving should be. One successful approach is to approximate a specific sifted set of numbers (e.g. the set of prime numbers) by another, simpler set (e.g. the set of almost prime numbers), which is typically somewhat larger than the original set, and easier to analyze. More sophisticated sieves also do not work directly with sets per se, but instead count them according to carefully chosen weight functions on these sets (options for giving some elements of these sets more "weight" than others). Furthermore, in some modern applications, sieves are used not to estimate the size of a sifted set, but to produce a function that is large on the set and mostly small outside it, while being easier to analyze than the characteristic function of the set. Basic sieve theory For information on notation see at the end. We start with some finite sequence of non-negative numbers . In the most basic case this sequence is just the indicator function of some set we want to sieve. However this abstraction allows for more general situations. Next we introduce a general set of prime numbers called the sifting range and their product up to as a function . The goal of sieve theory is to estimate the sifting function In the case of this just counts the cardinality of a subset of numbers, that are coprime to the prime factors of . Legendre's identity We can rewrite the sifting function with Legendre's identity by using the Möbius function and some functions induced by the elements of Example Let and . The Möbius function is negative for every prime, so we get Approximation of the congruence sum One assumes then that can be written