Sieve of Eratosthenes | Maths (original) (raw)

Last Updated : 17 Jul, 2025

The **Sieve of Eratosthenes is an ancient and efficient algorithm used to find all **prime numbers up to a given integer **n. It was developed by the Greek mathematician **Eratosthenes around 240 BCE. It is used in number theory ,cryptography and computer science for solving prime-related problems efficiently.

The functioning, importance, applications, and potential for efficient problem-solving of this algorithm will all be covered in this article.

Sieve of Eratosthenes Working

Prime-numbers-1-to-20

Follow the steps below to find the prime numbers up to n (n = 20 in our case)

**Result – The Prime Numbers up to 20: 2, 3, 5, 7, 11, 13, 17, 19

Prime Number up to 100

Here's how the Sieve of Eratosthenes works for numbers up to 100.

prime_numbers_1_to_103

Prime numbers 1 to 100

Given:- N is 100

The procedure of marking the prime numbers between 1 and 100 is as described below:

**Step 1: Write numbers from 1 to 100 in grid.

**Step 2: Cross out 1 (not prime).

**Step 3: Circle 2 (prime) and cross all its multiples.

**Step 4: Circle 3 and cross all its multiples.

**Step 5: Continue:

**Step 6: Continue until you've processed all numbers up to √100 (i.e 10). After that, all remaining uncrossed numbers in the list are primes.

So, The circled numbers are the prime numbers from 1 to 100 are {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97.}

Sieve of Eratosthenes Uses & Example

The Sieve of Eratosthenes is important because it provides a fast and simple way to find all prime numbers up to a given limit. Its efficiency makes it ideal for use in many computer algorithms where prime numbers are needed. It is used in different fields like:

**Computer Science: Used in hash functions, random number generators, and olving problems in algorithms.

**Cryptography: Helps in creating large prime numbers for secure systems like RSA..

**Mathematics: Acts as a core tool in number theory. Helps in studying the distribution of primes, prime factorization, and mathematical proofs involving primes.

**Signal Processing: Helps in building systems that send and receive signals.

**Engineering: Used in error-checking, networks, and digital design.

Practice Problem Based On Seive of Eratosthenes

**Question 1. Find all the prime numbers between 1 and 30.

**Question 2. Find all the prime numbers between 1 and 75.

**Question 3. List all the prime numbers up to 120 using the Sieve of Eratosthenes method.

**Question 4. List all the prime numbers up to 40 using the Sieve of Eratosthenes method.

**Answer:-

  1. 2, 3, 5, 7, 11, 13, 17, 19, 23, 29
  2. 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73.
  3. 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113.
  4. 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37

Also Read