EGCD
Updated 2023-10-13 20:04:17.943000
Syntax
SELECT [westclintech].[wct].[EGCD] (
<@Number1, float,>
,<@Number2, float,>)
Description
Use the scalar function EGCD to calculate the greatest common divisor using Euclid’s method
Arguments
@Number1
the first number used in the calculation. @Number1 is an expression of type float or of a type that can be implicitly converted to float.
@Number2
the first number used in the calculation. @Number2 is an expression of type float or of a type that can be implicitly converted to float.
Return Type
float
Remarks
EGCD calculates the greatest common divisor for two numbers. To calculate the greatest common divisor for more than two numbers it might be easier to use the aggregate function GCD.
Since the greatest common divisor is associative, it is entirely acceptable for either @Number1 or @Number2 to be the result of EGCD.
Examples
SELECT wct.EGCD(63, 728);
Here is the result set.
{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"7"}]}
SELECT wct.EGCD(81, wct.EGCD(63, 729));
Here is the result set.
{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":""},{"column 1":"9"}]}