Skip to content

Instantly share code, notes, and snippets.

@SilverCory
Created August 2, 2017 19:55
Show Gist options
  • Save SilverCory/f5ca9778277a570ab6d2177db1a6f7fb to your computer and use it in GitHub Desktop.
Save SilverCory/f5ca9778277a570ab6d2177db1a6f7fb to your computer and use it in GitHub Desktop.
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