Last active
January 1, 2016 09:59
-
-
Save r9y9/8128930 to your computer and use it in GitHub Desktop.
Fizz buzz 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
package main | |
import "fmt" | |
func FizzBuzz (i int) string { | |
switch { | |
case i % 3 == 0 && i % 5 == 0: | |
return "fizz buzz" | |
case i % 3 == 0: | |
return "fizz" | |
case i % 5 == 0: | |
return "buzz" | |
default: | |
return "" | |
} | |
} | |
func main() { | |
for i := 1; i < 100; i++ { | |
fmt.Println(i, FizzBuzz(i)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment