T-SQL, 153 (削除) 169 (削除ここまで) bytes
#T-SQL, 153 (削除) 169 (削除ここまで) bytes
SomeoneSomeone mentioned worst language for golfing?
CREATE FUNCTION G(@ INT,@B INT)RETURNS TABLE RETURN WITH R AS(SELECT 1D,0R UNION ALL SELECT D+1,@%(D+1)+@B%(D+1)FROM R WHERE D<@ and D<@b)SELECT MAX(D)D FROM R WHERE 0=R
Creates a table valued function (削除) that uses a recursive query to work out the common divisors. Then it returns the maximum (削除ここまで).
Now uses the euclidean algorithm to determine the GCD derived from my answer here.
Example usage
SELECT *
FROM (VALUES
(15,45),
(45,15),
(99,7),
(4,38)
) TestSet(A, B)
CROSS APPLY (SELECT * FROM G(A,B))GCD
A B D
----------- ----------- -----------
15 45 15
45 15 15
99 7 1
4 38 2
(4 row(s) affected)
#T-SQL, 153 (削除) 169 (削除ここまで) bytes
Someone mentioned worst language for golfing?
CREATE FUNCTION G(@ INT,@B INT)RETURNS TABLE RETURN WITH R AS(SELECT 1D,0R UNION ALL SELECT D+1,@%(D+1)+@B%(D+1)FROM R WHERE D<@ and D<@b)SELECT MAX(D)D FROM R WHERE 0=R
Creates a table valued function (削除) that uses a recursive query to work out the common divisors. Then it returns the maximum (削除ここまで).
Now uses the euclidean algorithm to determine the GCD derived from my answer here.
Example usage
SELECT *
FROM (VALUES
(15,45),
(45,15),
(99,7),
(4,38)
) TestSet(A, B)
CROSS APPLY (SELECT * FROM G(A,B))GCD
A B D
----------- ----------- -----------
15 45 15
45 15 15
99 7 1
4 38 2
(4 row(s) affected)
T-SQL, 153 (削除) 169 (削除ここまで) bytes
Someone mentioned worst language for golfing?
CREATE FUNCTION G(@ INT,@B INT)RETURNS TABLE RETURN WITH R AS(SELECT 1D,0R UNION ALL SELECT D+1,@%(D+1)+@B%(D+1)FROM R WHERE D<@ and D<@b)SELECT MAX(D)D FROM R WHERE 0=R
Creates a table valued function (削除) that uses a recursive query to work out the common divisors. Then it returns the maximum (削除ここまで).
Now uses the euclidean algorithm to determine the GCD derived from my answer here.
Example usage
SELECT *
FROM (VALUES
(15,45),
(45,15),
(99,7),
(4,38)
) TestSet(A, B)
CROSS APPLY (SELECT * FROM G(A,B))GCD
A B D
----------- ----------- -----------
15 45 15
45 15 15
99 7 1
4 38 2
(4 row(s) affected)
#T-SQL, 153 (削除) 169 (削除ここまで) bytes
Someone mentioned worst language for golfing?
CREATE FUNCTION G(@ INT,@B INT)RETURNS TABLE RETURN WITH R AS(SELECT 1D,0R UNION ALL SELECT D+1,@%(D+1)+@B%(D+1)FROM R WHERE D<@ and D<@b)SELECT MAX(D)D FROM R WHERE 0=R
Creates a table valued function (削除) that uses a recursive query to work out the common divisors. Then it returns the maximum (削除ここまで).
Now uses the euclidean algorithm to determine the GCD derived from my answer here here.
Example usage
SELECT *
FROM (VALUES
(15,45),
(45,15),
(99,7),
(4,38)
) TestSet(A, B)
CROSS APPLY (SELECT * FROM G(A,B))GCD
A B D
----------- ----------- -----------
15 45 15
45 15 15
99 7 1
4 38 2
(4 row(s) affected)
#T-SQL, 153 (削除) 169 (削除ここまで) bytes
Someone mentioned worst language for golfing?
CREATE FUNCTION G(@ INT,@B INT)RETURNS TABLE RETURN WITH R AS(SELECT 1D,0R UNION ALL SELECT D+1,@%(D+1)+@B%(D+1)FROM R WHERE D<@ and D<@b)SELECT MAX(D)D FROM R WHERE 0=R
Creates a table valued function (削除) that uses a recursive query to work out the common divisors. Then it returns the maximum (削除ここまで).
Now uses the euclidean algorithm to determine the GCD derived from my answer here.
Example usage
SELECT *
FROM (VALUES
(15,45),
(45,15),
(99,7),
(4,38)
) TestSet(A, B)
CROSS APPLY (SELECT * FROM G(A,B))GCD
A B D
----------- ----------- -----------
15 45 15
45 15 15
99 7 1
4 38 2
(4 row(s) affected)
#T-SQL, 153 (削除) 169 (削除ここまで) bytes
Someone mentioned worst language for golfing?
CREATE FUNCTION G(@ INT,@B INT)RETURNS TABLE RETURN WITH R AS(SELECT 1D,0R UNION ALL SELECT D+1,@%(D+1)+@B%(D+1)FROM R WHERE D<@ and D<@b)SELECT MAX(D)D FROM R WHERE 0=R
Creates a table valued function (削除) that uses a recursive query to work out the common divisors. Then it returns the maximum (削除ここまで).
Now uses the euclidean algorithm to determine the GCD derived from my answer here.
Example usage
SELECT *
FROM (VALUES
(15,45),
(45,15),
(99,7),
(4,38)
) TestSet(A, B)
CROSS APPLY (SELECT * FROM G(A,B))GCD
A B D
----------- ----------- -----------
15 45 15
45 15 15
99 7 1
4 38 2
(4 row(s) affected)
#T-SQL, 169153 (削除) 169 (削除ここまで) bytes
Someone mentioned worst language for golfing?
CREATE FUNCTION G(@ INT,@B INT)RETURNS TABLE RETURN WITH R AS(SELECT 1D,0R UNION ALL SELECT D+1,@%(D+1)+@B%(D+1)FROM R WHERE D<@ and D<@b)SELECT MAX(D)D FROM R WHERE 0=R
Creates a table valued function that(削除) that uses a recursive query to work out the common divisors. Then it returns the maximum (削除ここまで).
Now uses a recursive query to work out the common divisors. Then it returnseuclidean algorithm to determine the maximumGCD derived from my answer here.
Example usage
SELECT *
FROM (VALUES
(15,45),
(45,15),
(99,7),
(4,38)
) TestSet(A, B)
CROSS APPLY (SELECT * FROM G(A,B))GCD
A B D
----------- ----------- -----------
15 45 15
45 15 15
99 7 1
4 38 2
(4 row(s) affected)
#T-SQL, 169 bytes Someone mentioned worst language for golfing?
CREATE FUNCTION G(@ INT,@B INT)RETURNS TABLE RETURN WITH R AS(SELECT 1D,0R UNION ALL SELECT D+1,@%(D+1)+@B%(D+1)FROM R WHERE D<@ and D<@b)SELECT MAX(D)D FROM R WHERE 0=R
Creates a table valued function that uses a recursive query to work out the common divisors. Then it returns the maximum.
Example usage
SELECT *
FROM (VALUES
(15,45),
(45,15),
(99,7),
(4,38)
) TestSet(A, B)
CROSS APPLY (SELECT * FROM G(A,B))GCD
A B D
----------- ----------- -----------
15 45 15
45 15 15
99 7 1
4 38 2
(4 row(s) affected)
#T-SQL, 153 (削除) 169 (削除ここまで) bytes
Someone mentioned worst language for golfing?
CREATE FUNCTION G(@ INT,@B INT)RETURNS TABLE RETURN WITH R AS(SELECT 1D,0R UNION ALL SELECT D+1,@%(D+1)+@B%(D+1)FROM R WHERE D<@ and D<@b)SELECT MAX(D)D FROM R WHERE 0=R
Creates a table valued function (削除) that uses a recursive query to work out the common divisors. Then it returns the maximum (削除ここまで).
Now uses the euclidean algorithm to determine the GCD derived from my answer here.
Example usage
SELECT *
FROM (VALUES
(15,45),
(45,15),
(99,7),
(4,38)
) TestSet(A, B)
CROSS APPLY (SELECT * FROM G(A,B))GCD
A B D
----------- ----------- -----------
15 45 15
45 15 15
99 7 1
4 38 2
(4 row(s) affected)