Skip to content

Instantly share code, notes, and snippets.

@akshaybharambe14
Created March 10, 2020 17:11
Show Gist options
  • Save akshaybharambe14/b18b31b66f90c7523daf091b3fb4d501 to your computer and use it in GitHub Desktop.
Save akshaybharambe14/b18b31b66f90c7523daf091b3fb4d501 to your computer and use it in GitHub Desktop.
Function to count digits in a number in golang
package main
import (
"fmt"
)
func main() {
fmt.Println(CountDigits(1234454666))
}
func CountDigits(i int64) (count int64) {
for i > 0 {
i = i / 10
count++
}
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment