-
-
Notifications
You must be signed in to change notification settings - Fork 704
fixing a bug in perfect_power #40850
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
Conversation
|
You beat me to it! Looks good, just add a sentence before the new test saying |
Not too sure about how the docstring formatting works, this might require changing |
|
Documentation preview for this PR (built with commit 5649932; changes) is ready! 🎉 |
| if mpz_popcount(self.value) == 1: | ||
| return smallInteger(2), smallInteger(mpz_sizeinbase(self.value, 2) - 1) | ||
| if n < 1000: | ||
| elif n < 1000: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't it be better to test against len(_small_primes_table) (or store this in a constant)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't it be better to test against
len(_small_primes_table)(or store this in a constant)?
_small_primes_table is kind of weird. It's not a list or table of primes themselves. Rather, _small_primes_table[n] is 1 if 0 if _small_primes_table[0] = 0 because 1 is not prime, and _small_primes_table[1] = 1 because 3 is prime).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and similar logic is being employed in three different places in the code, ie, check if value < 1000 and is odd and if so, invoke _small_primes_table[value >> 1]. We should store this 1000 value in a constant.
|
I think that |
Sure.
With the PR
Previously 36 passed the first check and failed the second, then it checked if it was less than 1000 and if so whether |
|
|
comment added. Other changes left for other PRs. |
Let's add a |
|
we should really quickly set this one to "positive review" ; the rest is not urgent |
|
ok for me |
|
Thank you for the quick fix! |
|
Not needed for this PR, but since we were talking about it, some food for thought on
|
Fix sagemath#40846 ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. URL: sagemath#40850 Reported by: Frédéric Chapoton Reviewer(s): Martin Rubey, Sahil Jain, Vincent Macri
Fix #40846
📝 Checklist