Last active
August 29, 2015 14:06
-
-
Save andrewwatson/5aeb055ab5a5b91bffd9 to your computer and use it in GitHub Desktop.
My first version of fizzbuzz.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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".