Greatest Common Divisor
gcd(input1: Number | any[] | Mat, input2: Number | any[] | Mat) : Number| Mat
param input1
- Note: input1 and input2 must be the same type UNLESS you input a list only. The first input is the first part of the pair of items you want to find the gcd of. This function can find the gcd of two integers, or two 2d or 1d JS array/Mat objects
param input2
The other part of the pair. Must be identical to type of input1. Is the item to find the gcd of, whether its two integers, or two matrices, or two lists.
returns: Number | Mat
- The greatest common divisor is returned as an integer for the cases of 2 integers, OR it returns a Mat with the gcd in each indice element-wise. For example, given two 2x2 matrices, it will find the gcd of a[0][0] and b[0][0] and put it into the return matrix indice [0][0].
This function is the greatest common divisor function. The greatest common divisor is well known, but to reiterate, it is the shared integer between 2 (or more) numbers, such that it divides both of the numbers, and there is no number that can divide them that is larger. I.e. the largest shared divisor. This function returns the gcd of two integers and on top of that, if given lists, it will return the gcd element-wise of each list indice. If given just a list, it will give the gcd of all elements in that list. An example is shown below that may clear this up.