Skip to content

Conversation

@Navadeep0007
Copy link
Contributor

Description

Implements the Sieve of Eratosthenes algorithm for efficiently finding all prime numbers up to a given limit.

Issue

Closes #6939

Changes Made

  • ✅ Added SieveOfEratosthenes.java with complete implementation
  • ✅ Added SieveOfEratosthenesTest.java with comprehensive test cases
  • ✅ Includes JavaDoc documentation with complexity analysis
  • ✅ Handles edge cases (negative input, 0, 1, 2)
  • ✅ All tests passing

Algorithm Details

  • Time Complexity: O(n log log n)
  • Space Complexity: O(n)
  • Efficiently marks composite numbers using multiples

Testing

  • Tested with small numbers (0, 1, 2, 10, 30)
  • Tested with larger numbers (100, 1000)
  • Edge case testing (negative input)
  • All test cases passing ✅

Checklist

  • Code follows project style guidelines
  • Added unit tests
  • All tests pass
  • Added JavaDoc comments
  • No breaking changes

- Implement Sieve of Eratosthenes for finding prime numbers up to n
- Add comprehensive unit tests with edge cases
- Include JavaDoc documentation
- Time complexity: O(n log log n)
- Space complexity: O(n)

Resolves TheAlgorithms#6939
@codecov-commenter
Copy link

codecov-commenter commented Nov 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.35%. Comparing base (9381161) to head (e8df56a).

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #7071   +/-   ##
=========================================
  Coverage     78.35%   78.35%           
+ Complexity     6691     6689    -2     
=========================================
  Files           756      756           
  Lines         22212    22203    -9     
  Branches       4363     4365    +2     
=========================================
- Hits          17405    17398    -7     
+ Misses         4107     4106    -1     
+ Partials        700      699    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Navadeep0007
Copy link
Contributor Author

@DenizAltunkapan could you please review into my PR,
I appreciate your efforts!

Copy link
Member

@DenizAltunkapan DenizAltunkapan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Navadeep0007

@DenizAltunkapan DenizAltunkapan enabled auto-merge (squash) November 16, 2025 11:57
@DenizAltunkapan DenizAltunkapan merged commit c6880c1 into TheAlgorithms:master Nov 16, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE REQUEST] Sieve of Eratosthenes Algorithm

3 participants