Exercises & activities from the go workshop provided by Packt: https://courses.packtpub.com/courses/go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
302 B

  1. package main
  2. import (
  3. "fmt"
  4. "strconv"
  5. )
  6. func main() {
  7. var line string
  8. for i := 1; i <= 100; i++ {
  9. if i%3 == 0 {
  10. line += "Fizz"
  11. }
  12. if i%5 == 0 {
  13. line += "Buzz"
  14. }
  15. if len(line) == 0 {
  16. line = strconv.Itoa(i)
  17. }
  18. fmt.Println(line)
  19. line = ""
  20. }
  21. }