Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Alan] Modify sieve.alan (change size of primes array) #38

Merged
merged 2 commits into from
Sep 25, 2024

Conversation

harrisp28
Copy link
Contributor

Change size of primes array from 100 to 101 so primes[0] and primes[100] elements can be accessed (otherwise change code so we are not accessing them).

@kostis
Copy link
Owner

kostis commented Sep 25, 2024

Thanks for the PR and for noticing this inconsistency. I think that the code is still inconsistent because, when size us declared as 101, the array[100] entry is not initialized in the first while loop.

I would rather prefer a PR that makes sure all accesses to the primes[] array are consistent and within the [0,(n-1)] interval (i.e., that we never access the primes[n] entry). In other words, perhaps it's better to change the while loops on lines 33 and 43 to also use strict inequalities. Put it differently, I do not like that the conditions of the while loops are not uniform, currently.

Copy link
Owner

@kostis kostis left a comment

Choose a reason for hiding this comment

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

Looks good - thanks

@kostis kostis merged commit 94cbf66 into kostis:master Sep 25, 2024
2 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.

2 participants