-
-
Notifications
You must be signed in to change notification settings - Fork 46.8k
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
Comments
Dear @yuanyanhui, |
@ramkishanteli2 Seems only maintainers can assign issues. |
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. |
This issues seems to have been resolved in commit |
Has this issue been solved? If not, I would like to take this up. |
@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... |
Oh sorry @Bjiornulf, I completely missed your earlier comment. Yeah this issue seems fixed. Thanks! |
Hello, |
Uh oh!
There was an error while loading. Please reload this page.
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
The text was updated successfully, but these errors were encountered: