|
|
|
@ -1,20 +1,21 @@
|
|
|
|
|
# fishandchips |
|
|
|
|
## fishandchips |
|
|
|
|
|
|
|
|
|
### Instructions |
|
|
|
|
|
|
|
|
|
Write a function called `FishAndChips()` that takes an integer and returns a string. |
|
|
|
|
Write a function called `FishAndChips()` that takes an `int` and returns a `string`. |
|
|
|
|
|
|
|
|
|
- If the number is divisible by 2, print `fish` followed by a newline `\n`. |
|
|
|
|
- If the number is divisible by 3, print `chips` followed by a newline `\n`. |
|
|
|
|
- If the number is divisible by 2 and 3, print `fish and chips` followed by a newline `\n`. |
|
|
|
|
- If is not divisible by any of 3 and 2 print newline `\n`. |
|
|
|
|
|
|
|
|
|
### Expected function |
|
|
|
|
|
|
|
|
|
```go |
|
|
|
|
func FishAndChips(n int32) string { |
|
|
|
|
func FishAndChips(n int) string { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
### Usage |
|
|
|
|
|
|
|
|
|
Here is a possible program to test your function: |
|
|
|
@ -22,20 +23,25 @@ Here is a possible program to test your function:
|
|
|
|
|
```go |
|
|
|
|
package main |
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
"fmt" |
|
|
|
|
"piscine" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
func main() { |
|
|
|
|
args := []int32{0, 6, 33, -3, 5, 8} |
|
|
|
|
for i := 0; i < len(args); i++ { |
|
|
|
|
Fishandchips(args[i]) |
|
|
|
|
} |
|
|
|
|
fmt.Println(piscine.FishAndChips(4)) |
|
|
|
|
fmt.Println(piscine.FishAndChips(9)) |
|
|
|
|
fmt.Println(piscine.FishAndChips(6)) |
|
|
|
|
} |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
And its output: |
|
|
|
|
|
|
|
|
|
```go |
|
|
|
|
fish and chips$ |
|
|
|
|
fish and chips$ |
|
|
|
|
chips$ |
|
|
|
|
fish$ |
|
|
|
|
$ |
|
|
|
|
chips$ |
|
|
|
|
$ |
|
|
|
|
fish and chips$ |
|
|
|
|
$ |
|
|
|
|
``` |
|
|
|
|