Compute any-Base Logarithm in Go

Posted by yhuang
Public (Editable by Users)
Go
Edit
package main

import (
	"fmt"
	"math"
)

func LogAny(x, b float64) float64 {
  return math.Log(x) / math.Log(b)
}

func main() {
  fmt.Printf("%.1f", LogAny(27, 3))
}