Skip to content

Function number_of_divisors(n) returns wrong results #5999

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

Closed
yuanyanhui opened this issue Feb 15, 2022 · 8 comments
Closed

Function number_of_divisors(n) returns wrong results #5999

yuanyanhui opened this issue Feb 15, 2022 · 8 comments

Comments

@yuanyanhui
Copy link

yuanyanhui commented Feb 15, 2022

https://github.com/TheAlgorithms/Python/blob/master/maths/basic_maths.py
Function number_of_divisors(n) returns wrong results, e.g., number_of_divisors(6) produces 2. Correct answer should be 4.
After factorization, if n is not 1, this means it's a prime which has two divisors, thus the result should be multiplied by 2.
Solution: add the following code before function returns (line 60),
if n > 1: div *= 2

@yuanyanhui yuanyanhui changed the title Function number_of_divisors(n) Function number_of_divisors(n) returns wrong results Feb 15, 2022
@ramkishanteli2
Copy link

ramkishanteli2 commented Feb 17, 2022

Dear @yuanyanhui,
Could you assign this issue to me?
Thanks.

@yuanyanhui
Copy link
Author

@ramkishanteli2 Seems only maintainers can assign issues.

gr8rithic added a commit to gr8rithic/Python-1 that referenced this issue Feb 20, 2022
@stale
Copy link

stale bot commented Apr 25, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Used to mark an issue or pull request stale. label Apr 25, 2022
@Bjiornulf
Copy link
Contributor

This issues seems to have been resolved in commit 42a80cdaf689b03b326164862318039bd43bbff1 PR #6017.

@stale stale bot removed the stale Used to mark an issue or pull request stale. label Jul 14, 2022
@debjit-bw
Copy link
Contributor

debjit-bw commented Oct 1, 2022

Has this issue been solved? If not, I would like to take this up.

@Bjiornulf
Copy link
Contributor

@debjit-bw as I said in the previous comment, I think this has been solved in the pointed commit (you can take a look by yourself). Sadly I don't think this issue gets much attention, and I doubt it will ever be closed...

@debjit-bw
Copy link
Contributor

Oh sorry @Bjiornulf, I completely missed your earlier comment. Yeah this issue seems fixed. Thanks!

@nfarhaan
Copy link

Hello,
Can you assign this issue to me?

@cclauss cclauss closed this as completed Oct 29, 2022
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 a pull request may close this issue.

6 participants