Compare commits
No commits in common. "d1c3f6619b63d33db2bfb6ab08e3a1c99cf1f62d" and "92153118028b0bdc980c00dd4f79b3ebca5f4880" have entirely different histories.
d1c3f6619b
...
9215311802
10
ints/math.go
10
ints/math.go
@ -72,16 +72,6 @@ func Norm64(i int64) int64 {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// NthRoot returns the nth root of i.
|
|
||||||
func NthRoot(i, n int) int {
|
|
||||||
return int(math.Pow(float64(i), 1/float64(n)))
|
|
||||||
}
|
|
||||||
|
|
||||||
// NthRoot64 returns the nth root of i.
|
|
||||||
func NthRoot64(i, n int64) int64 {
|
|
||||||
return int64(math.Pow(float64(i), 1/float64(n)))
|
|
||||||
}
|
|
||||||
|
|
||||||
// SubAbs subtracts a from b and returns the absolute value of the result.
|
// SubAbs subtracts a from b and returns the absolute value of the result.
|
||||||
func SubAbs(a, b int) int {
|
func SubAbs(a, b int) int {
|
||||||
if a > b {
|
if a > b {
|
||||||
|
@ -62,28 +62,6 @@ func IsPalindromic(n int) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Len returns the number of digits of i (base 10, does not include a sign).
|
|
||||||
func Len(i int) int {
|
|
||||||
return Len64(int64(i))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Len64 returns the number of digits of i (base 10, does not include a sign).
|
|
||||||
func Len64(i int64) int {
|
|
||||||
if i == 0 {
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
if i < 0 {
|
|
||||||
i = 0 - i
|
|
||||||
}
|
|
||||||
|
|
||||||
digits := 0
|
|
||||||
for i > 0 {
|
|
||||||
i /= 10
|
|
||||||
digits++
|
|
||||||
}
|
|
||||||
return digits
|
|
||||||
}
|
|
||||||
|
|
||||||
// Permutations returns all possible permutations of the the set integers.
|
// Permutations returns all possible permutations of the the set integers.
|
||||||
func Permutations(set []int) [][]int {
|
func Permutations(set []int) [][]int {
|
||||||
var n = len(set)
|
var n = len(set)
|
||||||
|
Loading…
Reference in New Issue
Block a user