Skip to content

Instantly share code, notes, and snippets.

@vderyagin
Created November 13, 2012 19:14
Show Gist options
  • Save vderyagin/4067758 to your computer and use it in GitHub Desktop.
Save vderyagin/4067758 to your computer and use it in GitHub Desktop.
FizzBuzz in Go
package main
import "fmt"
func main() {
fizz_buzz()
}
func fizz_buzz() {
for num := 1; num <= 100; num++ {
divisible_by_three := num%3 == 0
divisible_by_five := num%5 == 0
if divisible_by_three {
fmt.Print("Fizz")
}
if divisible_by_five {
fmt.Print("Buzz")
}
if !(divisible_by_three || divisible_by_five) {
fmt.Print(num)
}
fmt.Println()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment