12345678910111213141516171819202122232425262728293031 |
- package main
- import (
- "math"
- )
- // ???
- func trailingZeroesOld(n int) int {
- cnt := 0
- for i := 5; i <= n; i += 5 {
- cnt += int(math.Log(float64(i)) / math.Log(5))
- }
- return cnt
- }
- func trailingZeroes(n int) int {
- var res int
- for n > 0 {
- n /= 5
- res += n
- }
- return res
- }
- // func main() {
- // fmt.Println(trailingZeroes(3))
- // fmt.Println(trailingZeroes(7))
- // fmt.Println(trailingZeroes(10))
- // fmt.Println(trailingZeroes(100))
- // fmt.Println(int(math.Log10(float64(125)) / math.Log10(5)))
- // }
|