Created
July 31, 2017 23:07
-
-
Save gmemstr/e7baf783f5202af7822d40af2c0fa2bf 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
/* | |
* Basic FizzBuzz excersize in Golang | |
*/ | |
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
i := 0 // Loop variable because go does not have "while" | |
for i <= 100 { // for ~= while | |
o := "" // String | |
// If multiple of 3 | |
if i % 3 == 0 { | |
o = "Fizz" | |
} | |
// If multiple of 5 | |
if i % 5 == 0 { | |
o = o+"Buzz" | |
} else { // If neither | |
o=fmt.Sprint(i) | |
} | |
fmt.Println(o) // Print | |
i++ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment