Created
May 27, 2018 21:47
-
-
Save selfcommit/db26558fb7cf5f946a734c9b27788e5c to your computer and use it in GitHub Desktop.
Playing around with a new language, time to write fizzbuzz
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" | |
func main() { | |
for i := 1; i <= 100; i++ { //Start at 1 to avoid 0 | |
var result = "" | |
if i%3 == 0{ | |
result = "Fizz" | |
} | |
if i%5 == 0{ | |
result = result + "Buzz" | |
} | |
if result == ""{ | |
fmt.Println(i) | |
}else{ | |
fmt.Println(result) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment