
I can code that FizzBuzz function with only two tests - plastic_teeth
http://boston.conman.org/2020/06/08.1
======
rethab
Or with AWK: echo 15 | awk '$1%3==0{s=s"Fizz"} $1%5==0{s=s"Buzz"} END{print
s}'

~~~
eesmith
Not that it affects your overall point, but you probably want:

    
    
      awk '$1%3==0{s=s"Fizz"} $1%5==0{s=s"Buzz"} {print s;s=""}'
    

Otherwise, consider:

    
    
      % printf "3\n5\n9\n15\n16\n" | awk '$1%3==0{s=s"Fizz"} $1%5==0{s=s"Buzz"} END{print s}'
      FizzBuzzFizzFizzBuzz
    
    

For bonus points, the following won't treat non-numerics as FizzBuzz:

    
    
      awk '$1+0\!=$1 {print"";next} $1%3==0{s=s"Fizz"} $1%5==0{s=s"Buzz"} {print s;s=""}'

------
brudgers
There is no clever way to compute FizzBuzz. It is a constant.

