diff --git a/ints/math.go b/ints/math.go index 86c8225..05c9065 100644 --- a/ints/math.go +++ b/ints/math.go @@ -72,6 +72,16 @@ func Norm64(i int64) int64 { 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. func SubAbs(a, b int) int { if a > b {