Documentation ¶
Index ¶
- Variables
- func Convergent(n int, fn convergentSeries) (*big.Int, *big.Int)
- func Cryptoquip(w1, w2 string) (map[byte]byte, bool)
- func CtrlT(str string, val *int, digits []int)
- func DigitSum(n int) (sum int)
- func DigitsToInt(digits []int) int
- func Divisors(n int) []int
- func E(n int) int64
- func Equal(a, b []int) bool
- func Factors(n int) []int
- func FactorsCounted(n int) map[int]int
- func Harshad(n, sum int) bool
- func IntToDigits(n int) []int
- func IsAnagram(w1, w2 string) bool
- func IsPalindromeInt(p []int) bool
- func IsPalindromeString(p string) bool
- func IsSquare(n int) bool
- func MakeDigits(n int, c chan []int)
- func PascalTriangle(max int) [][]int
- func PigLatin(s string) string
- func Reverse(digits []int) []int
- func Sqrt2(n int) int64
- func SquareFree(n int) bool
- func Totient(n int) int
- func Triangular(n int) bool
- func Wordify(n int) string
Constants ¶
This section is empty.
Variables ¶
var (
WordHundreds = []string{
"zero",
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
"nine",
"ten",
"eleven",
"twelve",
"thirteen",
"fourteen",
"fifteen",
"sixteen",
"seventeen",
"eighteen",
"nineteen",
}
)
Functions ¶
func Convergent ¶
Convergent returns the nth convegence of whichever series you pass in a function for.
func Cryptoquip ¶
Cryptoquip returns whether the two strings have the same relative arrangement of letters. For instance, KEEP and LOOT.
func DigitsToInt ¶
DigitsToInt converts a slice of digits to an int
func E ¶
E returns the nth number (1-based) in the convergent series of the number e [2; 1,2,1, 1,4,1, 1,6,1, ... ,1,2k,1, ...]
func FactorsCounted ¶
FactorsCounted returns a map of prime factors of n with counts of how many times each factor divides into n.
func IntToDigits ¶
IntToDigits converts an int into a slice of its component digits
func IsPalindromeInt ¶
IsPalindromeInt returns true if the digits of p are a palindrome
func IsPalindromeString ¶
IsPalindromeString returns true if the string is a palindrome
func MakeDigits ¶
MakeDigits generates all permutations of the first n digits. For example:
n=2 [1 2] [2 1] n=3 [1 2 3] [1 3 2] [2 1 3] [2 3 1] [3 1 2] [3 2 1]
func PascalTriangle ¶
PascalTriangle returns a triangle of the max depth specified We build the triangle left-justified. A cell is the sum of the cell above it and the cell above and to the left.
1: 1 2: 1 1 3: 1 2 1 4: 1 3 3 1 5: 1 4 6 4 1
func Sqrt2 ¶
Sqrt2 returns the nth number (1-based) in the convergent series of the square root of 2: [2;(2)]
func SquareFree ¶
SquareFree returns true if no square of a prime divides n
func Totient ¶
Totient returns how many numbers k are relatively prime to n where 1 <= k < n. Relatively prime means that they have no common divisors (other than 1). 1 is considered relatively prime to all other numbers.
From https://www.doc.ic.ac.uk/~mrh/330tutor/ch05s02.html
The general formula to compute φ(n) is the following:
If the prime factorisation of n is given by n =p1e1*...*pnen, then φ(n) = n *(1 - 1/p1)* ... (1 - 1/pn).
For example:
9 = 32, φ(9) = 9* (1-1/3) = 6
4 =22, φ(4) = 4* (1-1/2) = 2
15 = 3*5, φ(15) = 15* (1-1/3)*(1-1/5) = 15*(2/3)*(4/5) =8
Types ¶
This section is empty.