Skip to content

Instantly share code, notes, and snippets.

@scottchiang
Created April 19, 2013 08:26
Show Gist options
  • Save scottchiang/5418928 to your computer and use it in GitHub Desktop.
Save scottchiang/5418928 to your computer and use it in GitHub Desktop.
FizzBuzz in golang using switch statement
package main
import "fmt"
func main() {
for i := 1; i < 101; i++ {
switch {
case (i % 15) == 0: fmt.Println("FizzBuzz")
case (i % 3) == 0: fmt.Println("Fizz")
case (i % 5) == 0: fmt.Println("Buzz")
default: fmt.Println(i)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment