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

Weird and Semi-perfect numbers #18128

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

abhinav-anand-addepar
Copy link
Member

  • ntheory
    • Added new functions to implement semi-perfect numbers and weird numbers

@sympy-bot
Copy link

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:

  • ntheory

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.

 <!-- BEGIN RELEASE NOTES -->
* ntheory
  *  Added new functions to implement semi-perfect numbers and weird numbers
<!-- END RELEASE NOTES -->

@ethankward
Copy link
Contributor

For the numbers 66, 78, 102, 114, 138... your algorithm returns False, but these are semiperfect numbers.

@abhinav-anand-addepar
Copy link
Member Author

@ethankward I have made the required changes.

@ethankward
Copy link
Contributor

Why are you using this complicated algorithm instead of just using itertools.combinations?

@codecov
Copy link

codecov bot commented Dec 26, 2019

Codecov Report

Merging #18128 into master will increase coverage by 6.202%.
The diff coverage is 100%.

@@              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

@czgdp1807
Copy link
Member

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
>>> 

@czgdp1807
Copy link
Member

@abhinav28071999 Please resolve conflicts in this PR.

Comment on lines +2432 to +2434
if is_abundant(n) == True and is_semiperfect(n) == False:
return True
return False
Copy link
Member

@czgdp1807 czgdp1807 Feb 22, 2020

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.

@czgdp1807
Copy link
Member

@abhinav28071999 Would you still like to work on this?

@abhinav-anand-addepar
Copy link
Member Author

I will pass on this one. I will put a takeover label.

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

5 participants