public/subjects/numofdigits
MSilva95 33b0883b42 highlight 2022-08-04 12:02:45 +01:00
..
README.md highlight 2022-08-04 12:02:45 +01:00

README.md

number of digits

Instructions

Write a function that returns the number of digits in a positive integer n.

  • if the number is negative returns 0.

Expected function

func Numofdigits(num int) int {

}

Usage

Here is a possible program to test your function:

package main

import (
	"fmt"
)

func main() {
	fmt.Println(Numofdigits(3))
	fmt.Println(Numofdigits(245))
	fmt.Println(Numofdigits(-1))
	fmt.Println(Numofdigits(885))
	fmt.Println(Numofdigits(8574))
}

And its output :

$ go run .
1
3
0
3
4