Skip to main content
Log in

Mojo function

gcd

gcd(m: Int, n: Int, /) -> Int

Compute the greatest common divisor of two integers.

Args:

  • m (Int): The first integer.
  • n (Int): The second integrer.

Returns:

The greatest common divisor of the two integers.

gcd(s: Span[is_mutable, Int, lifetime], /) -> Int

Computes the greatest common divisor of a span of integers.

Args:

  • s (Span[is_mutable, Int, lifetime]): A span containing a collection of integers.

Returns:

The greatest common divisor of all the integers in the span.

gcd(l: List[Int, hint_trivial_type], /) -> Int

Computes the greatest common divisor of a list of integers.

Args:

  • l (List[Int, hint_trivial_type]): A list containing a collection of integers.

Returns:

The greatest common divisor of all the integers in the list.

gcd(*values: Int) -> Int

Computes the greatest common divisor of a variadic number of integers.

Args:

  • *values (Int): A variadic list of integers.

Returns:

The greatest common divisor of the given integers.

Was this page helpful?