Skip to content

Instantly share code, notes, and snippets.

@andrewwatson
Last active August 29, 2015 14:06
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 andrewwatson/5aeb055ab5a5b91bffd9 to your computer and use it in GitHub Desktop.
Save andrewwatson/5aeb055ab5a5b91bffd9 to your computer and use it in GitHub Desktop.
My first version of fizzbuzz.go
package main
import (
"fmt"
"strconv"
)
func main() {
for i := 0; i < 100; i++ {
output := strconv.Itoa(i)
output3 := ""
output5 := ""
if v := i % 3; v == 0 {
output = ""
output3 = "Fizz"
}
if v := i % 5; v == 0 {
output = ""
output5 = "Buzz"
}
fmt.Println(output + output3 + output5)
}
}
@andrewwatson
Copy link
Author

Instructions:
Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment