On this page
  1. math.gcd
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

math.gcd

Prev: math.gamma | Up: math | Next: math.hypot
Rel: math.acos, math.acosh, math.asin, math.asinh
Ref: docs.python.org — math.gcd
Tags: #public #python3 #stdlib #math


Import

import math
from math import gcd

Signature & Overview

math.gcd(*integers)

Greatest Common Divisor.

Usage

import math

assert math.gcd(48, 18) == 6
assert math.gcd(12, 18, 30) == 6

Gotchas

REPL Inspect

from math import gcd
help(gcd)

Linked from

Related notes