Shembull: Fizzbuzz

package main

import (
    "fmt"
)

func main() {
    for i := 1; i < 100; i++ {
        switch {
        case i%15 == 0:
            fmt.Println("fizzbuzz")
        case i%3 == 0:
            fmt.Println("fizz")
        case i%5 == 0:
            fmt.Println("buzz")
        default:
            fmt.Println(i)
        }
    }
}

https://play.golang.org/p/2u78tjXvVYP

Rezultati:

1
2
fizz
4
buzz
fizz
7
8
fizz
buzz
11
fizz
13
14
fizzbuzz
...
All Rights Reserved Theme by 404 THEME.