mirror of https://github.com/01-edu/public.git
Tiago Collot
2 years ago
1 changed files with 45 additions and 0 deletions
@ -0,0 +1,45 @@ |
|||||||
|
## rockandroll |
||||||
|
|
||||||
|
### Instructions |
||||||
|
|
||||||
|
Write a function called `RockAndRoll` that takes an integer and returns a string. |
||||||
|
|
||||||
|
- If the number is divisible by 2, print `rock` followed by a newline `\n`. |
||||||
|
- If the number is divisible by 3, print `roll` followed by a newline `\n`. |
||||||
|
- If the number is divisible by 2 and 3, print `rock and roll` followed by a newline `\n`. |
||||||
|
|
||||||
|
### Expected function |
||||||
|
|
||||||
|
```go |
||||||
|
func RockAndRoll(n int) string { |
||||||
|
|
||||||
|
} |
||||||
|
``` |
||||||
|
### Usage |
||||||
|
|
||||||
|
Here is a possible program to test your function: |
||||||
|
|
||||||
|
```go |
||||||
|
package main |
||||||
|
|
||||||
|
import ( |
||||||
|
"fmt" |
||||||
|
"strconv" |
||||||
|
) |
||||||
|
|
||||||
|
func main() { |
||||||
|
fmt.Println(RockAndRoll(4)) |
||||||
|
fmt.Println(RockAndRoll(9)) |
||||||
|
fmt.Println(RockAndRoll(6)) |
||||||
|
} |
||||||
|
``` |
||||||
|
And its output: |
||||||
|
|
||||||
|
```go |
||||||
|
rock$ |
||||||
|
$ |
||||||
|
roll$ |
||||||
|
$ |
||||||
|
rock and roll$ |
||||||
|
$ |
||||||
|
``` |
Loading…
Reference in new issue