Documentation
¶
Overview ¶
Package mathalgo provides algorithms about mathematics.
For better performance, all functions in this package are unsafe for concurrency unless otherwise specified.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GCD ¶
func GCD[Int constraints.Integer](xs ...Int) Int
GCD calculates the greatest common divisor of the integers xs.
The greatest common divisor of integers, which are not all zero, is the largest positive integer that divides each of the integers (zero is considered divisible by everything). In particular, if there is no nonzero integer, the greatest common divisor is considered zero.
According to the above definition, GCD always returns a nonnegative value, and it returns 0 if and only if there is no nonzero value in xs.
func LCM ¶
func LCM[Int constraints.Integer](xs ...Int) Int
LCM calculates the least common multiple of the integers xs.
The least common multiple of nonzero integers is the smallest positive integer that is divisible by each of the integers. In particular, if there is at least one zero, the least common multiple is considered zero, since zero is the only common multiple of zero and other integers.
According to the above definition, LCM always returns a nonnegative value, and it returns 0 if and only if len(xs) is 0 or there is at least one 0 in xs.
Types ¶
This section is empty.