aboutsummaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorDean Rasheed <dean.a.rasheed@gmail.com>2020-01-25 14:00:59 +0000
committerDean Rasheed <dean.a.rasheed@gmail.com>2020-01-25 14:00:59 +0000
commit13661ddd7eaec7e2809ff5c29fc14653b6161036 (patch)
tree478835d5b14b5b5c304face1c351079495cdbb38 /doc/src
parent530609aa4263bee5b5ca205d83f0dbad098d0465 (diff)
downloadpostgresql-13661ddd7eaec7e2809ff5c29fc14653b6161036.tar.gz
postgresql-13661ddd7eaec7e2809ff5c29fc14653b6161036.zip
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
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/func.sgml34
1 files changed, 34 insertions, 0 deletions
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
@@ -873,6 +873,40 @@
<row>
<entry>
<indexterm>
+ <primary>gcd</primary>
+ </indexterm>
+ <literal><function>gcd(<replaceable>a</replaceable>, <replaceable>b</replaceable>)</function></literal>
+ </entry>
+ <entry>(same as argument types)</entry>
+ <entry>
+ greatest common divisor (the largest positive number that divides both
+ inputs with no remainder); returns <literal>0</literal> if both inputs
+ are zero
+ </entry>
+ <entry><literal>gcd(1071, 462)</literal></entry>
+ <entry><literal>21</literal></entry>
+ </row>
+
+ <row>
+ <entry>
+ <indexterm>
+ <primary>lcm</primary>
+ </indexterm>
+ <literal><function>lcm(<replaceable>a</replaceable>, <replaceable>b</replaceable>)</function></literal>
+ </entry>
+ <entry>(same as argument types)</entry>
+ <entry>
+ least common multiple (the smallest strictly positive number that is
+ an integral multiple of both inputs); returns <literal>0</literal> if
+ either input is zero
+ </entry>
+ <entry><literal>lcm(1071, 462)</literal></entry>
+ <entry><literal>23562</literal></entry>
+ </row>
+
+ <row>
+ <entry>
+ <indexterm>
<primary>ln</primary>
</indexterm>
<literal><function>ln(<type>dp</type> or <type>numeric</type>)</function></literal>