Skip to content

Instantly share code, notes, and snippets.

@gmemstr
Created July 31, 2017 23:07
Show Gist options
  • Save gmemstr/e7baf783f5202af7822d40af2c0fa2bf to your computer and use it in GitHub Desktop.
Save gmemstr/e7baf783f5202af7822d40af2c0fa2bf to your computer and use it in GitHub Desktop.
/*
* Basic FizzBuzz excersize in Golang
*/
package main
import (
"fmt"
)
func main() {
i := 0 // Loop variable because go does not have "while"
for i <= 100 { // for ~= while
o := "" // String
// If multiple of 3
if i % 3 == 0 {
o = "Fizz"
}
// If multiple of 5
if i % 5 == 0 {
o = o+"Buzz"
} else { // If neither
o=fmt.Sprint(i)
}
fmt.Println(o) // Print
i++
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment