Updated 2018-04-01 09:36:04 by dbohdan

Fizz Buzz is a programming interview problem and exercise derived from a game meant to teach children arithmetic. The problem is stated as follows:
Print the numbers from 1 to 100 replacing numbers that are multiples of 3 with "Fizz", numbers that are multiples of 5 with "Buzz", and numbers that are multiples of both with "Fizz Buzz".

Solution  edit

dbohdan 2018-04-01: The canonical way to solve Fizz Buzz in Tcl is this:
for {set i 1} {$i <= 100} {incr i} {
    switch -glob [expr {$i % 3}]_[expr {$i % 5}] {
        0_0 { puts {Fizz Buzz} }
        0_* { puts Fizz }
        *_0 { puts Buzz }
        *_* { puts $i }
    }
}