Is likely a very easy challenge, but effective somehow.
Im wondering if there is a bash solution (one line, not a script) shorter than this mess I just did :
Code: Select all
for nn in `seq 1 100`; do { [ $(( $nn % 15 )) == 0 ] && echo "FizzBuzz"; } || { [ $(( $nn % 5 )) == 0 ] && echo "Buzz"; } || { [ $(( $nn % 3 )) == 0 ] && echo "Fizz"; } || ( echo "$nn") ; done | column
Code: Select all
perl -E 'say $_ % 15 ? $_ % 3 ? $_ % 5 ? "$_" : "Buzz" : "Fizz" : "Fizzbuzz" for 1 .. 100 ' | column
As I know that there is a lot of Bash wisdom surrounding, I'm wondering, are there better/shorter(/prettier) Bash ways?