Contents
gcd()
A function for obtaining the greatest common divisor
gcd()
is a system function for obtaining the greatest common divisor (the largest positive number that divides both inputs with no remainder).
gcd()
was added in PostgreSQL 13.
Usage
gcd (numeric_type
,numeric_type
) → numeric_type
Change history
- PostgreSQL 13
- added (commit 13661ddd; discussion: "Greatest Common Divisor")
Examples
postgres=# SELECT gcd(8,2); gcd ----- 2 (1 row) postgres=# SELECT gcd(8,3); gcd ----- 1 (1 row) postgres=# SELECT gcd(8,4); gcd ----- 4 (1 row)
References
- PostgreSQL documentation: Mathematical Functions