algebra

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convergent

func Convergent(n int, fn convergentSeries) (*big.Int, *big.Int)

Convergent returns the nth convergence of whichever series you pass in a function for

func DigitSum

func DigitSum(n int) int

DigitSum returns the sum of the digits in the number

func DigitsToInt

func DigitsToInt(digits []int) int

DigitsToInt converts a slice of digits to an int

func Divisors

func Divisors(n int) []int

Divisors returns a sorted list of all positive divisors of n

func E

func E(n int) int64

E returns the nth number (1-based) in the convergent series of e

func EqualIntSlice

func EqualIntSlice(a, b []int) bool

EqualIntSlice returns true if the two slices have identical contents

func Factors

func Factors(n int) []int

Factors returns a sorted list of the unique prime factors of n (excluding n)

func FactorsCounted

func FactorsCounted(n int) map[int]int

FactorsCounted returns counts of how many times each factor divides into n

func GCD

func GCD(a, b int) int

GCD returns the greatest common divisor of a and b

func GCDBigInt added in v0.0.11

func GCDBigInt(a, b *big.Int) *big.Int

GCDBigInt returns the greatest common divisor of a and b

func Harshad

func Harshad(n int) bool

Harshad returns true if n is divisible by the sum of its digits

func IntToDigits

func IntToDigits(n int) []int

IntToDigits converts an int into a slice of its component digits

func IsCube

func IsCube(n int) bool

IsCube returns true if n is a cube number

func IsInt

func IsInt(n float64) bool

IsInt returns true if n is an integer

func IsSquare

func IsSquare(n int) bool

IsSquare returns true if n is a square number

func LCM

func LCM(a, b int) int

LCM returns the least common multiple of a and b

func LCMBigInt added in v0.0.11

func LCMBigInt(a, b *big.Int) *big.Int

LCMBigInt returns the least common multiple of a and b

func MaxBigInt added in v0.0.11

func MaxBigInt(a, b *big.Int) *big.Int

MaxBigInt returns the largest of a or b

func MinBigInt added in v0.0.11

func MinBigInt(a, b *big.Int) *big.Int

MinBigInt returns the smallest of a or b

func MulFraction

func MulFraction(n1, d1, n2, d2 int) (int, int)

MulFraction returns the product of the two fractions, still in fraction form

func MulFractionBigInt added in v0.0.11

func MulFractionBigInt(n1, d1, n2, d2 *big.Int) (*big.Int, *big.Int)

MulFractionBigInt returns the product of the two fractions, still in fraction form

func NextSquare

func NextSquare(n uint) (uint, uint)

NextSquare returns the next highest square and its square root

func PascalTriangle

func PascalTriangle(max int) [][]int

PascalTriangle returns a triangle of the max depth specified

func ReduceFraction

func ReduceFraction(n, d int) (int, int)

ReduceFraction returns the lowest that n and d reduce to

func ReduceFractionBigInt added in v0.0.11

func ReduceFractionBigInt(n, d *big.Int) (*big.Int, *big.Int)

ReduceFractionBigInt returns the lowest that n and d reduce to

func Reverse

func Reverse(digits []int) []int

Reverse reverses the order of the elements in a slice

func Sqrt2

func Sqrt2(n int) int64

Sqrt2 returns the nth number (1-based) in the convergent series of root 2

func SquareFree

func SquareFree(n int) bool

SquareFree returns true if no square of a prime divides n

func SumFraction

func SumFraction(n1, d1, n2, d2 int) (int, int)

SumFraction returns the sum of the two fractions, still in fraction form

func SumFractionBigInt added in v0.0.11

func SumFractionBigInt(n1, d1, n2, d2 *big.Int) (*big.Int, *big.Int)

SumFractionBigInt returns the sum of the two fractions, still in fraction form

func Totient

func Totient(n int) int

Totient returns how many numbers k are relatively prime to n

Types

This section is empty.

Jump to

Keyboard shortcuts

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