-
- Notifications
You must be signed in to change notification settings - Fork 5.8k
Divisors.js #1435
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
base: master
Are you sure you want to change the base?
Divisors.js #1435
Conversation
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.
The algorithm implementation looks good to me. However, there are few suggestions I would like to provide:
- The function name is
printDivisors()
, but it doesn't prints anything, just returns a list of divisors. I suggest to change it to something likegetDivisors()
. - Change variable name into something meaningful .
- Also add documentations comment.
I have made the necessary changes and sent you a pull request. Please merge it. …On Thu, Oct 5, 2023 at 1:43 PM Gaurav Giri ***@***.***> wrote: ***@***.**** requested changes on this pull request. The algorithm implementation looks good to me. However, there are few suggestions I would like to provide: 1. The function name is printDivisors(), but it doesn't prints anything, just returns a list of divisors. I suggest to change it to something like getDivisors(). 2. Change variable name into something meaningful . 3. Also add documentations comment. — Reply to this email directly, view it on GitHub <#1435 (review)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AWWATJMLHEVSVWCTYGMGHFLX5ZT3NAVCNFSM6AAAAAA5TCI7SGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTMNJZGE3TQNBTHE> . You are receiving this because you authored the thread.Message ID: ***@***.***> |
Please merge PR #1435 if it's fine. |
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.
Great Work! Keep it up!
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.
Missing tests. @return{Vector}
should be @return{[]Integer}
(Integer
is treated as an undefined custom type; we could use number
, but that doesn't convey the same information. Ideally consider @typedef
ing Integer).
I'm also not sure how useful this algorithm is given that we already have prime factorization. (This gives you all divisors of a number, but I think that is almost always less useful than prime factorization.)
I have made the necessary changes in Divisors.js. Please review it. |
* @description Generate all unique divisors of a number. | ||
* @param {Integer} num | ||
* @return{[]Integer} divisors | ||
* @example{10-1,2,5,10} |
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 example is broken
It's still missing tests. |
I have added a file for computing all unique divisors of a number in javascript in Maths folder. Please merge my PR.