feat: remove duplicated gcd-like functions (#1642)

* feat: remove duplicated `gcd`-like functions

* Updated Documentation in README.md

---------

Co-authored-by: vil02 <vil02@users.noreply.github.com>
This commit is contained in:
Piotr Idzik
2024-03-16 04:59:14 +01:00
committed by GitHub
parent 0204198465
commit bd34e9fa61
4 changed files with 46 additions and 55 deletions

View File

@ -1,30 +0,0 @@
function euclideanGCDRecursive(first, second) {
/*
Calculates GCD of two numbers using Euclidean Recursive Algorithm
:param first: First number
:param second: Second number
:return: GCD of the numbers
*/
if (second === 0) {
return first
} else {
return euclideanGCDRecursive(second, first % second)
}
}
function euclideanGCDIterative(first, second) {
/*
Calculates GCD of two numbers using Euclidean Iterative Algorithm
:param first: First number
:param second: Second number
:return: GCD of the numbers
*/
while (second !== 0) {
const temp = second
second = first % second
first = temp
}
return first
}
export { euclideanGCDIterative, euclideanGCDRecursive }