Documentation
¶
Index ¶
- Constants
- func ChooseNUint32(ints []uint32, n int) [][]uint32
- func ExtendedGCD(a, b int) (gcd, quotientA, quotientB, bézoutCoefficientA, bézoutCoefficientB int)
- func GCD(a, b int) int
- func LCM(a, b int) int
- func ModExp(base, exponent, m int) int
- func ModGeometricSum(r, n, m int) (int, error)
- func ModInv(x, m int) (int, error)
- func ModMul(a, b, m int) int
- func MultiGCD(nums ...int) int
- func MultiLCM(nums ...int) int
- func Sieve(n int)
- func SlowPrimesLessThanOrEqualTo(target int) []int
- func Sort3(a, b, c int) (int, int, int)
- type Factor
Constants ¶
const MaxInt = int(MaxUint >> 1)
MaxInt is the max int value.
const MaxUint = ^uint(0)
MaxUint is the largest uint value.
const MinInt = -MaxInt - 1
MinInt is the smallest (negative) int value.
Variables ¶
This section is empty.
Functions ¶
func ChooseNUint32 ¶
ChooseNUint32 returns distinct groups of n uint32s from the inputs. It assumes the inputs are distinct too.
func ExtendedGCD ¶
func LCM ¶
LCM computes the least common multiple of a and b. It doesn't handle negative numbers. If either a or b is zero, it returns zero.
func ModGeometricSum ¶
ModGeometricSum returns the sum of the first n terms of the sequence rⁿ, starting with r⁰, modulo m. eg: ModGeometricSum(37, 5, 10000001) = (1 + 37 + 37² + 37³ + 37⁴) mod 10000001 = 1926221 eg: ModGeometricSum(37, 5, 101) = (1 + 37 + 37² + 37³ + 37⁴) mod 101 = 50
func ModInv ¶
ModInv calculates the modular multiplicative inverse of x, modulo m. If gcd(x,m) != 1, it returns an error.