mathalgo

package
v0.12.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2024 License: AGPL-3.0 Imports: 2 Imported by: 0

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 non-zero integer, the greatest common divisor is considered zero.

According to the above definition, GCD always returns a non-negative value, and it returns 0 if and only if there is no non-zero 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 non-zero 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 non-negative 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL