Created
April 11, 2019 10:53
-
-
Save benthurley82/a733de593f900ef7d5fda03fc287bd8d to your computer and use it in GitHub Desktop.
FizzBuzz test in Go created by benthurley82 - https://repl.it/@benthurley82/FizzBuzz-test-in-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
module main | |
go 1.12 |
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 ( | |
"strconv" | |
"fmt" | |
) | |
func main() { | |
for i := 1; i <= 100; i++ { | |
line := "" | |
if i%3 == 0 { | |
line += "Fizz" | |
} | |
if i%5 ==0 { | |
line += "Buzz" | |
} | |
if len(line) == 0 { | |
line = strconv.Itoa(i) | |
} | |
fmt.Println(line) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment