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.

43 lines
670 B

## CountStars
### Instructions
2 years ago
Write a function called `CountStars` that counts the stars up to a number given as an argument.
- If the number is negative or equal to 0, return "`No stars`"
- No need to manage overflow.
### Expected Function
```go
func CountStars(num int) string {
}
```
2 years ago
### Usage
Here is a possible program to test your function :
```go
2 years ago
package main
import "fmt"
func main() {
fmt.Println(CountStars(5))
fmt.Println(CountStars(4))
fmt.Println(CountStars(-1))
fmt.Println(CountStars(1))
}
```
2 years ago
And its output :
```console
$ go run .
1 star...2 stars...3 stars...4 stars...5 stars
1 star...2 stars...3 stars...4 stars
No stars
1 star
```