Documentation
¶
Index ¶
- func Abs(x int) int
- func Binomial(n, k int) int
- func Digits(x int) <-chan int
- func DigitsBig(x *big.Int) <-chan int
- func Factorial(n int) int
- func GCD(numbers ...int) int
- func GetDivisors(x int) <-chan int
- func GetDivisorsBruteForce(x int) <-chan int
- func GetPrimeNumbers() (<-chan int, chan<- bool)
- func GetPrimeNumbersBelow(n int) <-chan int
- func LCM(numbers ...int) int
- func LCMBig(numbers ...*big.Int) *big.Int
- func Max(numbers ...int) int
- func MaxPath(t *Tree) int
- func NumberOfDigits(x int) int
- func NumberOfDigitsBig(x *big.Int) int
- func NumberOfDivisors(x int) int
- func NumberOfDivisorsBruteForce(x int) int
- func Pow(x, y int) int
- func PrimeFactorisation(x int) <-chan PrimeFactor
- func SumOfDivisors(x int) int
- func SumOfDivisorsBruteForce(x int) int
- type PrimeFactor
- type Tree
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Binomial ¶
Binomial returns to binomial coefficient of (|n|, |k|). It does not handle int overflows when numbers get too large. Use big.Binomial() instead.
func Digits ¶
Digits returns and fills a channel with the digits of x starting with the smallest magnitude numbers (right to left).
func DigitsBig ¶
DigitsBig fills and returns a channel with the digits of x starting with the smallest magnitude numbers (right to left).
func Factorial ¶
Factorial returns the factorial of |n|. It does not handle int overflows when numbers get too large. Use big.MulRange() instead.
func GCD ¶
GCD returns the greatest common divisor of a group of integers. GCD() = 0 GCD(a, 0) = |a| Does not handle math.MinInt64
func GetDivisors ¶ added in v1.1.1
GetDivisors fills a channel with all the (positive) divisors of x, unsorted. Uses PrimeFactorisation(x). Does not handle math.MinInt64.
func GetDivisorsBruteForce ¶ added in v1.1.1
GetDivisorsBruteForce fills a channel with all the (positive) divisors of x, unsorted. Uses a brute force method.
func GetPrimeNumbers ¶
GetPrimeNumbers returns a channel from which to siphon off the prime numbers in order, as needed. Send a boolean to the Done channel when finished. The prime sieve: Daisy-chain Filter processes.
func GetPrimeNumbersBelow ¶
GetPrimeNumbersBelow fills a channel with the prime numbers below |n|. Uses a euclidean sieve.
func LCM ¶
LCM returns the least common multiple of a group of integers. This method uses GCD(). LCM() = 0 LCM(a, 0) = |a| Does not handle int overflows if the numbers get too large. Use LCMBig.
func LCMBig ¶
LCMBig returns the least common multiple of a group of integers. This method uses (*Int) GCD(). LCMBig() = 0 LCMBig(a, 0) = |a|
func MaxPath ¶
MaxPath returns the largest of all the possible summations from top to bottom of a tree. The execution works up from the bottom of the pyramid. The maximum path to a node is the value of the node plus the maximum of the maximum paths to each child node. There is a natural recursive function but it fails when a pyramid tree gets too large and the function runs out of resources. MaxPath(<nil>) returns 0.
func NumberOfDigits ¶
NumberOfDigits returns the number of digits x has. Uses integer-string conversion.
func NumberOfDigitsBig ¶
NumberOfDigitsBig returns the number of digits x has. Uses integer-string conversion.
func NumberOfDivisors ¶
NumberOfDivisors returns the number of (positive) divisors of x. Uses PrimeFactorisation(x). Does not handle math.MinInt64.
func NumberOfDivisorsBruteForce ¶ added in v1.1.1
NumberOfDivisorsBruteForce returns the number of (positive) divisors of x. Uses a brute force method.
func PrimeFactorisation ¶
func PrimeFactorisation(x int) <-chan PrimeFactor
PrimeFactorisation sends the prime factorisation of |x| on a channel, in ascending order. If x is 0 or 1, PrimeFactorisation(x) returns a PrimeFactor with value x, index 1. Does not handle math.MinInt64.
func SumOfDivisors ¶
SumOfDivisors returns the sum of all (positive) divisors of x. Uses PrimeFactorisation(x). Does not handle math.MinInt64.
func SumOfDivisorsBruteForce ¶ added in v1.1.1
SumOfDivisorsBruteForce returns the sum of all (positive) divisors of x. Uses a brute force method.
Types ¶
type PrimeFactor ¶
type PrimeFactor struct {
Value, Index int
}
PrimeFactor is designed to hold a prime number as 'value' and the index of the prime number when it appears in a complete prime factorisation product.
type Tree ¶
A Tree has a value and two sub trees.
func CreateBinaryTree ¶
CreateBinaryTree returns a (mostly) symmetric binary tree, filling with values from top to bottom, left to right. CreateBinaryTree() returns <nil>
func CreatePyramidTree ¶
CreatePyramidTree returns a (mostly) symmetric pyramid tree, filling with values from top to bottom, left to right. CreatePyramidTree() returns <nil>