Created
August 2, 2017 19:55
-
-
Save SilverCory/f5ca9778277a570ab6d2177db1a6f7fb to your computer and use it in GitHub Desktop.
This file contains hidden or 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" | |
// DO NOT READ THIS CODE BEFORE YOU DO THE CHALLENGE! | |
// | |
// | |
// The challenge: | |
// From 1 to 100; | |
// for every multiple of 3, print 'fizz'. | |
// for every multiple of 5, print 'buzz'. | |
// For multiples of 3 and 5, print 'fizzbuzz'. | |
// | |
// | |
// After you have done so, watch this: https://www.youtube.com/watch?v=QPZ0pIK_wsc | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
// | |
func main() { | |
for i := 1; i < 101; i++ { | |
printed := false | |
if i%3 == 0 { | |
fmt.Print("Fizz") | |
printed = true | |
} | |
if i%5 == 0 { | |
fmt.Print("Buzz") | |
printed = true | |
} | |
if !printed { | |
fmt.Println(i) | |
} else { | |
fmt.Println() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment