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.

48 lines
823 B

## fishandchips
2 years ago
### Instructions
Write a function called `FishAndChips()` that takes an `int` and returns a `string`.
2 years ago
- If the number is divisible by 2, print `fish`.
- If the number is divisible by 3, print `chips`.
- If the number is divisible by 2 and 3, print `fish and chips`.
- If the number is negative return `error: number is negative`.
- If the number is non divisible by 2 or 3 return `error: non divisible`.
2 years ago
### Expected function
```go
func FishAndChips(n int) string {
2 years ago
}
```
2 years ago
### Usage
Here is a possible program to test your function:
2 years ago
```go
package main
import (
"fmt"
"piscine"
)
2 years ago
func main() {
fmt.Println(piscine.FishAndChips(4))
fmt.Println(piscine.FishAndChips(9))
fmt.Println(piscine.FishAndChips(6))
2 years ago
}
```
And its output:
2 years ago
```console
$ go run . | cat -e
fish$
2 years ago
chips$
fish and chips$
2 years ago
```