
Strange product
The function strangeProduct
is given a series of integers and returns the product of all numbers in the series that are greater than 7 and multiple of 4. For example, if the numbers in the series are 12, 3, 4, 8, 9, 2, the function will return 96 (the product of 12 and 8). The lines of the function have been jumbled. Place the lines into the correct order.
*= n
product }
return product
}
for _, n := range numbers {
if n > 7 && n%4 == 0 {
:= 1
product func strangeProduct(numbers []int) int {
}
To test the function you can use the main
below:
func main() {
const N = 10
:= make([]int, N)
numbers
for i := 0; i < N; i++ {
.Scan(&numbers[i])
fmt}
.Println(strangeProduct(numbers)
fmt}