Skip to content

Instantly share code, notes, and snippets.

@jonbodner
Created September 14, 2018 02:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonbodner/20d3f1fcf6f30b60ab0d8f9f2bad7b49 to your computer and use it in GitHub Desktop.
Save jonbodner/20d3f1fcf6f30b60ab0d8f9f2bad7b49 to your computer and use it in GitHub Desktop.
FizzBuzz without if statements
package main
import (
"fmt"
"strconv"
)
func main() {
vals := [][]string{{"FizzBuzz", "Fizz"}, {"Buzz", ""}}
for i := 1; i <= 100; i++ {
vals[1][1] = strconv.Itoa(i)
x := ((i % 3) + 2) / 3
y := ((i % 5) + 4) / 5
fmt.Println(vals[x][y])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment