monty.fractions module

Math functions.

gcd(*numbers)[source]

Returns the greatest common divisor for a sequence of numbers.

Parameters

*numbers – Sequence of numbers.

Returns

(int) Greatest common divisor of numbers.

gcd_float(numbers, tol=1e-08)[source]

Returns the greatest common divisor for a sequence of numbers. Uses a numerical tolerance, so can be used on floats

Parameters
  • numbers – Sequence of numbers.

  • tol – Numerical tolerance

Returns

(int) Greatest common divisor of numbers.

lcm(*numbers)[source]

Return lowest common multiple of a sequence of numbers.

Parameters

*numbers – Sequence of numbers.

Returns

(int) Lowest common multiple of numbers.