Skip to content

Conversation

Naman-Vasudev
Copy link

Describe your change:

  • Add an algorithm

This PR adds an optimized implementation of the Sieve of Eratosthenes.
The optimization skips even numbers after 2 and uses a half-sized boolean array,
reducing both memory and time by approximately 50% compared to the standard sieve.

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work.
  • This PR only changes one algorithm file.
  • All function parameters and return values are annotated with type hints.
  • All functions have doctests that pass automated testing.
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
@algorithms-keeper algorithms-keeper bot added the require descriptive names This PR needs descriptive function and/or variable names label Oct 20, 2025
Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.


from math import isqrt

def optimized_sieve(n: int) -> list[int]:

Choose a reason for hiding this comment

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

Please provide descriptive name for the parameter: n

@algorithms-keeper algorithms-keeper bot added the awaiting reviews This PR is ready to be reviewed label Oct 20, 2025
@algorithms-keeper algorithms-keeper bot removed the require descriptive names This PR needs descriptive function and/or variable names label Oct 20, 2025
@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Oct 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting reviews This PR is ready to be reviewed tests are failing Do not merge until tests pass

1 participant