Created
March 7, 2014 12:03
-
-
Save showmurai/9410257 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
| package main | |
| import ( | |
| "flag" | |
| "fmt" | |
| "strconv" | |
| ) | |
| var n *int = flag.Int("n", 100, "Setting Last position. (default is 100)") | |
| func main() { | |
| flag.Parse() | |
| fmt.Println("Let's start FizzBuzz!") | |
| for i := 1; i <= *n; i++ { | |
| fmt.Println(i, fizzbuzz(i)) | |
| } | |
| } | |
| func fizzbuzz(i int) string { | |
| if i%3 == 0 && i%5 == 0 { | |
| return "FizzBuzz" | |
| } else if i%3 == 0 { | |
| return "Fizz" | |
| } else if i%5 == 0 { | |
| return "Buzz" | |
| } | |
| return strconv.Itoa(i) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment