Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Solution: FizzBuzz

package main

import (
	"fmt"
	"strconv"
)

func main() {
	for n := 1; n < 100; n++ {
		resp := ""

		if n%3 == 0 {
			resp += "Fizz"
		}
		if n%5 == 0 {
			resp += "Buzz"
		}
		if resp == "" {
			resp = strconv.Itoa(n)
		}

		fmt.Println(resp)
	}
}