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

update Primes.jl #86

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

update Primes.jl #86

wants to merge 2 commits into from

Conversation

deva567
Copy link

@deva567 deva567 commented Jun 19, 2020

Earlier primes(0) will through error like "The condition lo ≤ hi must be met." but now
primes(0) will return output as look like primes(0,0).

Earlier primes(0) will through like "The condition lo ≤ hi must be met." but 
primes(0) will return output as look like primes(0,0).
@rfourquet
Copy link
Member

Thanks! This would need a bit more work to be merged: for changes like this, we need tests to avoid regressions. Also, given that e.g. primes(-10, -4) works, I believe we should update primes(n) such that this never throws, i.e. even for n<0, not only n==0.

@deva567
Copy link
Author

deva567 commented Jun 20, 2020

@rfourquet just for clarification , we need to produce output for primes(-10,-4) as same as like primes(4,10) and one more thing primes(-10) whether it should equal to primes(0,10).
FYI attached sample PNG files

sample1

sample

@rfourquet
Copy link
Member

No, we have this method: primes(n) = primes(1, n), but conceptually this would be primes(n) = primes(-infinity, n). So for m <= n <1, we have isempty(primes(m, n)) == true, i.e. no primes are negative. So primes(n) for n < 1 should just return the empty list as well.

@deva567
Copy link
Author

deva567 commented Jun 20, 2020

@rfourquet
one1
FYI attached sample output and made changes in Primes.jl with the help of "if -else" now it can handle negative integer when we gave one parameter to the function and wont through error like earlier

The Primes() will accept now one parameter which may be  the negative or positive integer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants