There's a leetcode test 326. Power of Three with a Mathematics method with java:
public class Solution {
public boolean isPowerOfThree(int n) {
return (Math.log(n) / Math.log(3) + epsilon) % 1 <= 2 * epsilon;
}
}
When I intend to convert this solution to Golang Like
import "math"
func isPowerOfThree(n int) bool {
return (math.Log10(float64(n)) / math.Log10(3)) % 1 == 0.0
}
then here comes the compile error like
Line 4: Char 53: invalid operation: math.Log10(float64(n)) / math.Log10(3) % 1 (operator % not defined on float64) (solution.go)
I check the math package but there's no supported function like % operator, Is there any valid operator like % in Golang? thanks a lot :)