TheAlgorithms/JavaScript

[OTHER]: Duplicate entry of sieve of eratosthenes

SpiderMath opened this issue · 23 comments

What would you like to share?

There's three entries in total for Sieve of Eratosthenes on the website, but the problem is that there's a primary one out of the three which has a majority of the implementations, including that of JS. However, there's another one which has just another JS implementation of the exact same thing, and it's named Sieve of Eratosthenes Int Array, which is both a weird name and just a random duplicate entry. Since it only had a JS entry, I wasn't sure if I should open an issue on the website repo or here, hence I thought as this was a JS repo issue I'd open it here.
So, do we remove the duplicate entry from the repository?

Additional information

No response

I think we can get rid of https://github.com/TheAlgorithms/JavaScript/blob/master/Maths/SieveOfEratosthenesIntArray.js; it is strictly inferior to https://github.com/TheAlgorithms/JavaScript/blob/master/Maths/SieveOfEratosthenes.js (except perhaps for being a bit simpler, at the cost of being less optimized).

Since you've added the beginner-friendly tag, do you wish to keep this issue open for any beginners to take it up or should I do it now and push the changes? (considering we only need to remove certain files)

Since you've added the beginner-friendly tag, do you wish to keep this issue open for any beginners to take it up or should I do it now and push the changes? (considering we only need to remove certain files)

Feel free to do it now

There are three entries for the Sieve of Eratosthenes on the website, with one primary entry containing most implementations, including JavaScript. However, there's another entry named "Sieve of Eratosthenes Int Array," which is a duplicate with only a JavaScript implementation and a confusing name.

  • Remove the "Sieve of Eratosthenes Int Array" entry to avoid confusion and maintain consistency.
  • Ensure no unique features or references are lost in the process.

Please review and confirm if this is a suitable approach.

There are two Sieve of Eratosthenes entries in the website ( I think they are duplicate ). It returns an array of boolean which tells the numbers are true or false.

There is another one Sieve of Eratosthenes Int Array it return the Array of numbers that are primes only and it doesn't contains any non prime numbers.

I think Sieve of Eratosthenes Int Array should not be removed, while out of two Sieve of Eratosthenes entries one should be removed because I think they are duplicate.
Please tell if I am in right direction.

As I said, I think removing the "Int Array" variant is fine. Then there is only one Sieve of Eratosthenes left.

There is a pr with the necessary change, but they seem to have abandoned it without removing the related tests.

is this issue still on??

Yes.

i think i got the problem, we should remove one of the implementation right?
so can u tell me what user will actually require...like
https://the-algorithms.com/algorithm/sieve-of-eratosthenes-int-array
this will be required when the user wants all the prime number between a given range meanwhile
https://the-algorithms.com/algorithm/sieve-of-eratosthenes?lang=javascript
this will be required when user wants to check primality of numbers or generate prime status for boolean array .

and according to me user will definitely want 1st one more than the 2nd one...so we should remove the 2nd one...this is the problem right??

I think it doesn't matter much. Both variants can easily be turned into the other via postprocessing. I feel https://the-algorithms.com/algorithm/sieve-of-eratosthenes-int-array is a bit cleaner, whereas the other one might be a bit more optimized. But ultimately they both implement the core idea of the Sieve of Eratosthenes.

Thank you for your input! I agree that both implementations can achieve the same goal through post-processing, and it's great to have flexibility. However, from a user-experience standpoint, we should prioritize clarity and ease of use.
Most users will likely want a list of prime numbers (like in the int array implementation), which is simple and immediately useful for most practical applications. The boolean array implementation, while optimized, adds a layer of abstraction that users may not need unless they specifically want to check primality across a range of numbers.
So, for simplicity and to avoid confusion, I still think we should keep just one implementation, ideally https://the-algorithms.com/algorithm/sieve-of-eratosthenes-int-array. This way, we streamline the codebase and make it more user-friendly without compromising on functionality.

What do you think about this approach?

and can u tell me what you are also thinking specifically...i.e. to remove one of the two or just change the name or heading?

Remove one of the two, possibly rename it (if we're keeping the "int array" one, we would want to rename that to just "Sieve of Eratosthenes"), consolidate the tests.

Sounds good!
I agree with removing one of the implementations and renaming the remaining one to "Sieve of Eratosthenes" for clarity. I'll go ahead and:
->Remove the boolean array implementation.
->Rename the int array version to simply "Sieve of Eratosthenes."
->Consolidate the tests to ensure everything works smoothly.
I'll start working on this and submit a PR shortly. Let me know if there's anything else you'd like to add!?

I would love to contribute in this , if it open, it is my first time , can you please guide me.

Hi if this is still open maybe I could work on it. I am a beginner.

Hey is this still available?

Hey!! please assign this to me if it's still available.

Hi I like to work with this. Is it still open to work

Hii, If they issue is still open i would like to work on this. Could you please assign me so that i can work on it

This issue won't be assigned to anyone, open a pull request and it will be reviewed.

  • Remove the boolean array implementation.
  • Rename the int array version to simply "Sieve of Eratosthenes."
  • Consolidate the tests to ensure everything works smoothly.