Documentation ¶
Overview ¶
Package math is a package that contains mathematical algorithms and its different implementations.
filename : krishnamurthy.go description: A program which contains the function that returns true if a given number is Krishnamurthy number or not. details: A number is a Krishnamurthy number if the sum of all the factorials of the digits is equal to the number. Ex: 1! = 1, 145 = 1! + 4! + 5! author(s): [GooMonk](https://github.com/GooMonk) see krishnamurthy_test.go
Index ¶
- Variables
- func Abs(n int) int
- func AliquotSum(n int) (int, error)
- func Combinations(n int, k int) (int, error)
- func Cos(x float64) float64
- func DefaultPolynomial(n *big.Int) func(*big.Int) *big.Int
- func FindKthMax(nums []int, k int) (int, error)
- func FindKthMin(nums []int, k int) (int, error)
- func IsAutomorphic[T constraints.Integer](n T) bool
- func IsKrishnamurthyNumber[T constraints.Integer](n T) bool
- func IsPerfectNumber(inNumber uint) bool
- func IsPowOfTwoUseLog(number float64) bool
- func Lerp(v0, v1, t float64) float64
- func LiouvilleLambda(n int) (int, error)
- func Mean[T constraints.Number](values []T) float64
- func Median[T constraints.Number](values []T) float64
- func Mode[T constraints.Number](numbers []T) (T, error)
- func Mu(n int) int
- func Phi(n int64) int64
- func PollardsRhoFactorization(n *big.Int, f func(n *big.Int) func(x *big.Int) *big.Int) (*big.Int, error)
- func PronicNumber(n int) bool
- func Sin(x float64) float64
- func SumOfProperDivisors(inNumber uint) uint
Constants ¶
This section is empty.
Variables ¶
var ErrEmptySlice = errors.New("empty slice provided")
ErrEmptySlice is the error returned by functions in math package when an empty slice is provided to it as argument when the function expects a non-empty slice.
var ErrNonZeroArgsOnly error = errors.New("arguments cannot be zero")
var ErrPosArgsOnly error = errors.New("arguments must be positive")
Functions ¶
func Combinations ¶
C is Binomial Coefficient function This function returns C(n, k) for given n and k
func Cos ¶
Cos returns the cosine of the radian argument x. [See more](https://en.wikipedia.org/wiki/Sine_and_cosine) [Based on the idea of Bhaskara approximation of cos(x)](https://math.stackexchange.com/questions/3886552/bhaskara-approximation-of-cosx)
func DefaultPolynomial ¶
DefaultPolynomial is the commonly used polynomial g(x) = (x^2 + 1) mod n
func FindKthMax ¶
FindKthMax returns the kth large element given an integer slice with nil `error` if found and returns -1 with `error` `search.ErrNotFound` if not found. NOTE: The `nums` slice gets mutated in the process.
func FindKthMin ¶
FindKthMin returns kth small element given an integer slice with nil `error` if found and returns -1 with `error` `search.ErrNotFound` if not found. NOTE: The `nums` slice gets mutated in the process.
func IsAutomorphic ¶
func IsAutomorphic[T constraints.Integer](n T) bool
func IsKrishnamurthyNumber ¶
func IsKrishnamurthyNumber[T constraints.Integer](n T) bool
IsKrishnamurthyNumber returns if the provided number n is a Krishnamurthy number or not.
func IsPerfectNumber ¶
Checks if inNumber is a perfect number
func IsPowOfTwoUseLog ¶
IsPowOfTwoUseLog This function checks if a number is a power of two using the logarithm. The limiting degree can be from 0 to 63. See alternatives in the binary package.
func Lerp ¶
Lerp or Linear interpolation This function will return new value in 't' percentage between 'v0' and 'v1'
func LiouvilleLambda ¶
Lambda is the liouville function This function returns λ(n) for given number
func Mean ¶
func Mean[T constraints.Number](values []T) float64
func Median ¶
func Median[T constraints.Number](values []T) float64
func Mode ¶
func Mode[T constraints.Number](numbers []T) (T, error)
func Phi ¶
Phi is the Euler totient function. This function computes the number of numbers less then n that are coprime with n.
func PollardsRhoFactorization ¶
func PollardsRhoFactorization(n *big.Int, f func(n *big.Int) func(x *big.Int) *big.Int) (*big.Int, error)
PollardsRhoFactorization is an implementation of Pollard's rho factorization algorithm using the default parameters x = y = 2
func PronicNumber ¶
PronicNumber returns true if argument passed to the function is pronic and false otherwise.
func Sin ¶
Sin returns the sine of the radian argument x. [See more](https://en.wikipedia.org/wiki/Sine_and_cosine)
func SumOfProperDivisors ¶
Returns the sum of proper divisors of inNumber.
Types ¶
This section is empty.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package binary describes algorithms that use binary operations for different calculations.
|
Package binary describes algorithms that use binary operations for different calculations. |
Package factorial describes algorithms Factorials calculations.
|
Package factorial describes algorithms Factorials calculations. |
Package geometry contains geometric algorithms
|
Package geometry contains geometric algorithms |
filename: strassenmatrixmultiply.go description: Implements matrix multiplication using the Strassen algorithm.
|
filename: strassenmatrixmultiply.go description: Implements matrix multiplication using the Strassen algorithm. |