gcd()

A system 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.

Change history

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)
  • PostgreSQL documentation: gcd()

Categories

System function

See also

lcm()