-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
adding fix #1342 fixing docs for FenWickTree and DepthFirstSearch #1647
base: master
Are you sure you want to change the base?
Changes from all commits
1650272
96985a6
5aa8bfa
575eead
18edde7
1ec1979
ae93e49
7560357
c70f197
8f10dee
de118c6
d64f4c9
f9a154b
1d37ed9
d9cc779
ad98cee
8d5cc4b
fb5530f
7ae0aad
2f74313
3d06ddf
780fb91
714cd66
53035ec
42b95ed
d82e849
8aab6f9
7651b8b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,10 @@ | |
*/ | ||
|
||
// factorial utility method. | ||
/** | ||
* @param {Number} n | ||
* @returns {Number} the factiorial of n | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo: factiorial (I would also say this is self-explanatory, and since it's just a helper, doesn't need a comment; ideally this file should import the factorial implementation). |
||
*/ | ||
const factorial = (n) => { | ||
let fact = 1 | ||
while (n !== 0) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,10 +7,12 @@ | |
Complexity: | ||
O(sqrt(n)) | ||
*/ | ||
|
||
/** | ||
* | ||
* @param {Number} n | ||
* @returns {Number} count of numbers b/w 1 and n that are coprime to n | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "b/w" is confusing. Please write "between" out. This should also be consolidated with the definition given above. |
||
*/ | ||
export const EulersTotient = (n) => { | ||
// input: n: int | ||
// output: phi(n): count of numbers b/w 1 and n that are coprime to n | ||
let res = n | ||
for (let i = 2; i * i <= n; i++) { | ||
if (n % i === 0) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,9 @@ | |
* https://www.mathsisfun.com/definitions/factor.html | ||
* | ||
*/ | ||
|
||
/** | ||
* @param {Number} [number=0] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not useful. |
||
*/ | ||
const factorsOfANumber = (number = 0) => { | ||
return Array.from(Array(number + 1).keys()).filter( | ||
(num) => number % num === 0 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,12 @@ | |
More about HCF: | ||
https://en.wikipedia.org/wiki/Greatest_common_divisor | ||
*/ | ||
|
||
/** | ||
* | ||
* @param {Number} x | ||
* @param {Number} y | ||
* @returns {(string|number)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be explained; ideallly the errors should be thrown instead of returned. |
||
*/ | ||
const findHCF = (x, y) => { | ||
// If the input numbers are less than 1 return an error message. | ||
if (x < 1 || y < 1) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,12 @@ | |
import { findHCF } from './FindHcf' | ||
|
||
// Find the LCM of two numbers. | ||
/** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unhelpful comment |
||
* | ||
* @param {Number} num1 | ||
* @param {Number} num2 | ||
* @returns | ||
*/ | ||
const findLcm = (num1, num2) => { | ||
// If the input numbers are less than 1 return an error message. | ||
if (num1 < 1 || num2 < 1) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,10 @@ | |
Source: https://en.wikipedia.org/wiki/Friendly_number | ||
See also: https://mathworld.wolfram.com/FriendlyNumber.html#:~:text=The%20numbers%20known%20to%20be,numbers%20have%20a%20positive%20density. | ||
*/ | ||
|
||
/** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, this comment is unhelpful |
||
* @param {Number} firstNumber, | ||
* @param {Number} secondNumber | ||
*/ | ||
export const FriendlyNumbers = (firstNumber, secondNumber) => { | ||
// input: two integers | ||
// output: true if the two integers are friendly numbers, false if they are not friendly numbers | ||
|
@@ -22,11 +25,17 @@ export const FriendlyNumbers = (firstNumber, secondNumber) => { | |
|
||
return abundancyIndex(firstNumber) === abundancyIndex(secondNumber) | ||
} | ||
|
||
/** | ||
* @param {Number} number | ||
*/ | ||
function abundancyIndex(number) { | ||
return sumDivisors(number) / number | ||
} | ||
|
||
/** | ||
* | ||
* @param {Number} number | ||
* @returns | ||
*/ | ||
function sumDivisors(number) { | ||
let runningSumDivisors = number | ||
for (let i = 0; i < number / 2; i++) { | ||
|
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 three lines starting here are not useful.