Login     Register

        Contact Us     Search

XLeratorDB/math Documentation

SQL Server Euclidean greatest common divisor function


EGCD
 
Updated: 17 August 2010
Use EGCD to calculate the greatest common divisor using Euclid’s method
Syntax
SELECT [westclintech].[wct].[EGCD] (
   <@Number1, float,>
 ,<@Number2, float,>)
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 Types
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
----------------------
7
 
(1 row(s) affected)
 
SELECT wct.EGCD(81, wct.EGCD(63, 729))

 ----------------------

9

(1 row(s) affected)


Copyright 2008-2017 Westclintech LLC         Privacy Policy        Terms of Service