You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
549 B

## number of digits
### Instructions
2 years ago
Write a function that returns the number of digits in a positive integer n.
2 years ago
- if the number is negative returns 0.
### Expected function
```go
func Numofdigits(num int) int {
}
```
### Usage
2 years ago
Here is a possible program to test your function:
```go
package main
import (
2 years ago
"fmt"
)
func main() {
2 years ago
fmt.Println(Numofdigits(3))
fmt.Println(Numofdigits(245))
fmt.Println(Numofdigits(-1))
fmt.Println(Numofdigits(885))
fmt.Println(Numofdigits(8574))
}
```
And its output :
```console
$ go run .
1
3
0
3
4