ArticleslgStudy

science

Sieve of Sundaram

Sieve of Sundaram is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Sieve of Sundaram rather than just read about it. In short: In mathematics, the sieve of Sundaram is a variant of the sieve of Eratosthenes, a simple deterministic algorithm for finding all the prime numbers up to a specified integer. It was discovered by Indian student S.

Sieve of Sundaram — main illustration
Sieve of Sundaram — illustration

Key takeaways

  • Sieve of Sundaram belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Sieve of Sundaram to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Sieve of Sundaram from memory before moving on to harder problems.

Reference excerpt

In mathematics, the sieve of Sundaram is a variant of the sieve of Eratosthenes, a simple deterministic algorithm for finding all the prime numbers up to a specified integer. It was discovered by Indian student S. P. Sundaram in 1934.

Algorithm

The sieve starts with a list of the integers from 1 to n. From this list, all numbers of the form i + j + 2ij are removed, where i and j are positive integers such that 1 ≤ i ≤ j and i + j + 2ij ≤ n. The remaining numbers are doubled and incremented by one, giving a list of the odd prime numbers (that is, all primes except 2) below 2n + 2. The sieve of Sundaram sieves out the composite numbers just as the sieve of Eratosthenes does, but even numbers are not considered; the work of "crossing out" the multiples of 2 is done by the final double-and-increment step. Whenever Eratosthenes' method would cross out k different multiples of a prime 2i + 1, Sundaram's method crosses out i + j(2i + 1) for 1 ≤ j ≤ ⌊k/2⌋.

Correctness If we start with integers from 1 to n, the final list contains only odd integers from 3 to 2n + 1. From this final list, some odd integers have been excluded; we must show these are precisely the composite odd integers less than 2n + 2. Let q be an odd integer of the form 2k + 1. Then, q is excluded if and only if k is of the form i + j + 2ij, that is q = 2(i + j + 2ij) + 1. Then q = (2i + 1)(2j + 1). So, an odd integer is excluded from the final list if and only if it has a factorization of the form (2i + 1)(2j + 1) — which is to say, if it has a non-trivial odd factor. Therefore the list must be composed of exactly the set of odd prime numbers less than or equal to 2n + 2.

Asymptotic complexity

The above obscure-but-commonly-implemented{{Citation needed|reason=If this code, which is neither pseudo nor functionally correct, is such a prominent implementation of this algorithm to the point that this false example is to be displayed instead of a functional example, then it should be justified with a source to its origin. |date=June 2026}} Python version of the Sieve of Sundaram hides the true complexity of the algorithm due to the following reasons:

The range for the outer i looping variable is much too large, resulting in redundant looping that cannot perform any composite number culling; the proper range is to the array indices that represent odd numbers less than √n. The code does not properly account for indexing of Python arrays, which are zero-based so that it ignores the values at the bottom and top of the array; this is a minor issue, but serves to show that the algorithm behind the code has not been clearly understood. The inner culling loop (the j loop) exactly reflects the way the algorithm is formulated, but seemingly without realizing that the indexed culling starts at exactly the index representing the square of the base odd number and that the indexing using multiplication can much more easily be expressed as a simple repeated addition of the base odd number across the range; in fact, this method of adding a constant value across the culling range is exactly how the Sieve of Eratosthenes culling is generally implemented. Using Python-as-pseudocode, the following Python code resolves the above issues other than keeping the unused one element that arises from indexing from one-based indexing used with zero-based indexing Python:

The commented-out line is all that is necessary to convert the Sieve of Sundaram to the Odds-Only Sieve of Eratosthenes; this clarifies that the only difference between these two algorithms is that the Sieve of Sundaram culls composite numbers using all odd numbers as the base values, whereas the Odds-Only Sieve of Eratosthenes uses only the odd primes as base values, with both ranges of base values bounded to the square root of the range.{{Citation needed|reason=If this code, which is over optimized to the point of reduced readability, is such a prominent implementation of this algorithm to the point that this example is to be displayed instead of a simple and functionally complete example, then it should be justified with a source to its origin. |date=June 2026}} When run for various ranges, it is immediately clear that while, of course, the resulting count of primes for a given range is identical between the two algorithms, the number of culling operations is much higher for the Sieve of Sundaram and also grows much more quickly with increasing range. From the above implementation, it is clear that the amount of work done is given by

∫ a b n 2 x d x , {\displaystyle \int _{a}^{b}{\frac {n}{2x}}\,dx,}

where n is the range to be sieved and the interval [a, b] is the odd numbers between 3 and √n. (The interval [a, b] actually starts at the square of the odd base values, but this difference is negligible for large ranges.) As the integral of the reciprocal of x is exactly log(x), and as the lower value for a is relatively very small (close to 1, whose logarithm is 0), this is about

n 8 log ⁡ ( n ) . {\displaystyle {\frac {n}{8}}\log(n).}

Ignoring the constant factor of 1/8, the asymptotic complexity is clearly O(n log(n)).

See also Sieve of Eratosthenes Sieve of Atkin Sieve theory

References

Further reading Ogilvy, C. Stanley; John T. Anderson (1988). Excursions in Number Theory. Dover Publications, 1988 (reprint from Oxford University Press, 1966). pp. 98–100, 158. ISBN 0-486-25778-9. Honsberger, Ross (1970). Ingenuity in Mathematics. New Mathematical Library #23. Mathematical Association of America. pp. 75. ISBN 0-394-70923-3. Movshovitz-Hadar, N. (1988). "Stimulating Presentations of Theorems Followed by Responsive Proofs". For the Learning of Mathematics. 8 (2): 12–19. Ferrando, Elisabetta (2005). Abductive processes in conjecturing and proving (PDF) (PhD). Purdue University. pp. 70–72. Baxter, Andrew. "Sundaram's Sieve". Topics from the History of Cryptography. MU Department of Mathematics. Archived from the original on 2019-04-20. Retrieved 2026-07-16.

External links A C99 implementation of the Sieve of Sundaram using bitarrays

Worked examples

Example 1 — a first encounter with Sieve of Sundaram

Start with the simplest possible case. Write down what Sieve of Sundaram claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Sieve of Sundaram before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Sieve of Sundaram ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Sieve of Sundaram

In research
Sieve of Sundaram appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Sieve of Sundaram in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Sieve of Sundaram is common in secondary-school and first-year university syllabi. It links to neighbouring topics Indian inventions, Primality tests, so understanding it makes those chapters shorter.
In everyday life
Look for Sieve of Sundaram outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Sieve of Sundaram” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Sieve of Sundaram in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Sieve of Sundaram means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Sieve of Sundaram out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Sieve of Sundaram in simple terms?

In mathematics, the sieve of Sundaram is a variant of the sieve of Eratosthenes, a simple deterministic algorithm for finding all the prime numbers up to a specified integer. It was discovered by Indian student S.

Why does Sieve of Sundaram matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Sieve of Sundaram?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Sieve of Sundaram.

Tags

  • Indian inventions
  • Primality tests

Keep exploring