Skip to content

[FEATURE REQUEST] Sieve of Eratosthenes Algorithm #6939

@Shewale41

Description

@Shewale41

What would you like to Propose?

Title: Add Sieve of Eratosthenes for Prime Number Generation


🧠 Overview

The Sieve of Eratosthenes efficiently generates all prime numbers up to a given integer N using a simple marking approach.

📂 Implementation Details

  • Folder: src/main/java/com/thealgorithms/maths/
  • Filename: SieveOfEratosthenes.java
  • Approach:
    • Initialize boolean array of size N+1.
    • Mark multiples of each prime starting from 2.
    • Collect unmarked numbers as primes.

✅ Expected Deliverables

  • Implementation printing or returning all primes ≤ N.
  • Unit tests for small (N=30) and large inputs.
  • Commented explanation of time complexity O(N log log N).

🧑‍💻 Additional Notes

A classic algorithm essential to number theory, perfect for the “Maths” section.

Issue details

🧠 Overview

The Sieve of Eratosthenes efficiently generates all prime numbers up to a given integer N using a simple marking approach.

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions