From 13661ddd7eaec7e2809ff5c29fc14653b6161036 Mon Sep 17 00:00:00 2001 From: Dean Rasheed Date: Sat, 25 Jan 2020 14:00:59 +0000 Subject: Add functions gcd() and lcm() for integer and numeric types. These compute the greatest common divisor and least common multiple of a pair of numbers using the Euclidean algorithm. Vik Fearing, reviewed by Fabien Coelho. Discussion: https://postgr.es/m/adbd3e0b-e3f1-5bbc-21db-03caf1cef0f7@2ndquadrant.com --- doc/src/sgml/func.sgml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'doc/src') diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 6c4359dc7be..895b4b7b1b6 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -870,6 +870,40 @@ -43 + + + + gcd + + gcd(a, b) + + (same as argument types) + + greatest common divisor (the largest positive number that divides both + inputs with no remainder); returns 0 if both inputs + are zero + + gcd(1071, 462) + 21 + + + + + + lcm + + lcm(a, b) + + (same as argument types) + + least common multiple (the smallest strictly positive number that is + an integral multiple of both inputs); returns 0 if + either input is zero + + lcm(1071, 462) + 23562 + + -- cgit v1.2.3