forked from root/public
Compare commits
7 Commits
master
...
1147-count
Author | SHA1 | Date |
---|---|---|
zainabdnaya | d2d2628c39 | 2 years ago |
zainabdnaya | 6ce6c9f28a | 2 years ago |
zainabdnaya | 6fecafde19 | 2 years ago |
zainabdnaya | 4bc9674ad7 | 2 years ago |
zainabdnaya | 1327b88dcc | 2 years ago |
zainabdnaya | 4988c57bfc | 2 years ago |
zainabdnaya | c672f5a43b | 2 years ago |
1 changed files with 43 additions and 0 deletions
@ -0,0 +1,43 @@ |
|||||||
|
## CountStars |
||||||
|
|
||||||
|
### Instructions |
||||||
|
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. |
||||||
|
|
||||||
|
The Library strconv is allowed. |
||||||
|
|
||||||
|
### Expected Function |
||||||
|
|
||||||
|
```go |
||||||
|
func CountStars(num int) string { |
||||||
|
|
||||||
|
} |
||||||
|
``` |
||||||
|
### Usage |
||||||
|
|
||||||
|
Here is a possible program to test your function : |
||||||
|
|
||||||
|
```go |
||||||
|
import ( |
||||||
|
"fmt" |
||||||
|
"strconv" |
||||||
|
) |
||||||
|
|
||||||
|
func main() { |
||||||
|
fmt.Println(CountStars(5)) |
||||||
|
fmt.Println(CountStars(4)) |
||||||
|
fmt.Println(CountStars(-1)) |
||||||
|
fmt.Println(CountStars(1)) |
||||||
|
} |
||||||
|
``` |
||||||
|
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 |
||||||
|
``` |
Loading…
Reference in new issue