Skip to content

Instantly share code, notes, and snippets.

@showmurai
Created March 7, 2014 12:03
Show Gist options
  • Select an option

  • Save showmurai/9410257 to your computer and use it in GitHub Desktop.

Select an option

Save showmurai/9410257 to your computer and use it in GitHub Desktop.
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