Skip to content

Instantly share code, notes, and snippets.

@r9y9
Last active January 1, 2016 09:59
Show Gist options
  • Save r9y9/8128930 to your computer and use it in GitHub Desktop.
Save r9y9/8128930 to your computer and use it in GitHub Desktop.
Fizz buzz in go
package main
import "fmt"
func FizzBuzz (i int) string {
switch {
case i % 3 == 0 && i % 5 == 0:
return "fizz buzz"
case i % 3 == 0:
return "fizz"
case i % 5 == 0:
return "buzz"
default:
return ""
}
}
func main() {
for i := 1; i < 100; i++ {
fmt.Println(i, FizzBuzz(i))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment