-
Notifications
You must be signed in to change notification settings - Fork 20.7k
Open
Labels
Description
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