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
Weird and Semi-perfect numbers #18128
base: master
Are you sure you want to change the base?
Conversation
abhinav-anand-addepar
commented
Dec 25, 2019
- ntheory
- Added new functions to implement semi-perfect numbers and weird numbers
✅ Hi, I am the SymPy bot (v149). I'm here to help you write a release notes entry. Please read the guide on how to write release notes. Your release notes are in good order. Here is what the release notes will look like:
This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.6. Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it. Click here to see the pull request description that was parsed.
|
For the numbers 66, 78, 102, 114, 138... your algorithm returns |
@ethankward I have made the required changes. |
Why are you using this complicated algorithm instead of just using |
Codecov Report
@@ Coverage Diff @@
## master #18128 +/- ##
=============================================
+ Coverage 68.733% 74.935% +6.202%
=============================================
Files 642 642
Lines 166965 166991 +26
Branches 39281 39291 +10
=============================================
+ Hits 114761 125136 +10375
+ Misses 46657 36316 -10341
+ Partials 5547 5539 -8 |
What about symbolic inputs? >>> is_semiperfect(n)
Traceback (most recent call last):
File "/home/czgdp1807/sympy_project/sympy/sympy/core/compatibility.py", line 419, in as_int
raise TypeError
TypeError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/code.py", line 91, in runcode
exec(code, self.locals)
File "<console>", line 1, in <module>
File "/home/czgdp1807/sympy_project/sympy/sympy/ntheory/factor_.py", line 2394, in is_semiperfect
factors = divisors(n)
File "/home/czgdp1807/sympy_project/sympy/sympy/ntheory/factor_.py", line 1438, in divisors
n = as_int(abs(n))
File "/home/czgdp1807/sympy_project/sympy/sympy/core/compatibility.py", line 425, in as_int
raise ValueError('%s is not an integer' % (n,))
ValueError: Abs(n) is not an integer
>>> |
@abhinav28071999 Please resolve conflicts in this PR. |
if is_abundant(n) == True and is_semiperfect(n) == False: | ||
return True | ||
return False |
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.
It can be transformed to a one liner, return is_abundant(n) == True and is_semiperfect(n) == False
.
IMO, this function simply uses two pre-defined functions without much manipulations, so we can remove is_weird
.
@abhinav28071999 Would you still like to work on this? |
I will pass on this one. I will put a takeover label. |