Keith-S-Thompson/fizzbuzz-polyglot

Shorter shell

Closed this issue · 0 comments

Not really an issue but with both bash and zsh fizzbuzz can be done like this

for i in {1..100}; do
    ret=""
    ((i % 3 == 0)) && ret="Fizz"
    ((i % 5 == 0)) && ret="${ret}Buzz"
    [[ -n $ret ]]  && echo "$ret" || echo "$i"
done

Feel free to close this or take it as an addition, cool repo though either way :)

Cheers