Math Functions

math.gcd()

Find the nonnegative greatest common divisor of integer inputs. No arguments or all zero arguments give zero.

Formal Syntax & Structure

python syntaxpython
math.gcd(*integers)

Parameters & Attributes

NameTypeDescription
integersintZero or more integer operands.

Return Value

int

Integer result, exact for integer arithmetic.

Working Example

Example Snippetpython
import mathprint(math.gcd(42, 30, 18))
Python Reference