Skip to content

Instantly share code, notes, and snippets.

@selfcommit
Created May 27, 2018 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save selfcommit/db26558fb7cf5f946a734c9b27788e5c to your computer and use it in GitHub Desktop.
Save selfcommit/db26558fb7cf5f946a734c9b27788e5c to your computer and use it in GitHub Desktop.
Playing around with a new language, time to write fizzbuzz
package main
import "fmt"
func main() {
for i := 1; i <= 100; i++ { //Start at 1 to avoid 0
var result = ""
if i%3 == 0{
result = "Fizz"
}
if i%5 == 0{
result = result + "Buzz"
}
if result == ""{
fmt.Println(i)
}else{
fmt.Println(result)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment