Documentation ¶
Overview ¶
math is a package with some generic math functions.
Index ¶
- func DevRem[T constraints.Integer](x, y T) (T, T)
- func Divide[T constraints.Integer | constraints.Float](x, y T) T
- func Fibonacci[T constraints.Integer](n T) T
- func Gcd[T constraints.Integer](a, b T) T
- func IsPrime[T constraints.Integer](n T) bool
- func Lcm[T constraints.Integer](a, b T) T
- func MillerRabin[T constraints.Integer](n T) bool
- func PascalsTriangle(n int) []int
- func PerfectNumber[T constraints.Integer](n T) T
- func PowFloat[T constraints.Float](x, y T) T
- func PowInt[T constraints.Integer](x, y T) T
- func PrimesTo[T constraints.Integer](n T) []T
- func SieveOfSundaram[T constraints.Integer](n T) []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DevRem ¶
func DevRem[T constraints.Integer](x, y T) (T, T)
DevRem returns the division and remainder of x/y.
func Fibonacci ¶
func Fibonacci[T constraints.Integer](n T) T
Fibonacci returns the nth Fibonacci number.
func Gcd ¶
func Gcd[T constraints.Integer](a, b T) T
Gcd returns the greatest common divisor of a and b.
func IsPrime ¶
func IsPrime[T constraints.Integer](n T) bool
IsPrime returns true if n is must have prime.
func Lcm ¶
func Lcm[T constraints.Integer](a, b T) T
Lcm returns the least common multiple of a and b.
func MillerRabin ¶
func MillerRabin[T constraints.Integer](n T) bool
MillerRabin returns true if n is probably prime.
func PascalsTriangle ¶
PascalTriangle returns the Pascal's triangle for the given n.
func PerfectNumber ¶
func PerfectNumber[T constraints.Integer](n T) T
PerfectNumber returns perfect numbers to n.
func PrimesTo ¶
func PrimesTo[T constraints.Integer](n T) []T
PrimesTo returns the prime numbers from 2 to n.
func SieveOfSundaram ¶
func SieveOfSundaram[T constraints.Integer](n T) []T
SieveOfSundaram returns the prime numbers from 2 to n.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.