Skip to content

Instantly share code, notes, and snippets.

@rnemeth90
Last active July 18, 2022 14:38
Show Gist options
  • Save rnemeth90/063288d38cfc534e2c6c59a3b31107ef to your computer and use it in GitHub Desktop.
Save rnemeth90/063288d38cfc534e2c6c59a3b31107ef to your computer and use it in GitHub Desktop.
Go FizzBuzz
package main
import (
"fmt"
"strconv"
)
func fizzbuzz(num int) string {
switch {
case num%15 == 0:
return "FizzBuzz"
case num%3 == 0:
return "Fizz"
case num%5 == 0:
return "Buzz"
}
return strconv.Itoa(num)
}
func main() {
for num := 1; num <= 100; num++ {
fmt.Println(fizzbuzz(num))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment