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.

50 lines
934 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` followed by a newline `\n`.
2 years ago
- 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 the number is negative return `error: number is negative` followed by a newline `\n`.
- If the number is non divisible return `error: non divisible` followed by a newline `\n`.
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
fish$
$
2 years ago
chips$
$
fish and chips$
2 years ago
$
```