Exercises & activities from the go workshop provided by Packt: https://courses.packtpub.com/courses/go
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.
 

26 lines
335 B

package main
import "fmt"
func main() {
for i := 1; i <= 15; i++ {
n, s := fizzBuzz(i)
fmt.Printf("Results: %d %s\n", n, s)
}
}
func fizzBuzz(i int) (int, string) {
switch {
case i%15 == 0:
return i, "FizzBuzz"
case i%3 == 0:
return i, "Fizz"
case i%5 == 0:
return i, "Buzz"
}
return i, ""
}