Skip to content

Instantly share code, notes, and snippets.

@johnxx
Created July 10, 2019 15:06
Show Gist options
  • Save johnxx/1c795b6788c1f683c72adf5288a74b98 to your computer and use it in GitHub Desktop.
Save johnxx/1c795b6788c1f683c72adf5288a74b98 to your computer and use it in GitHub Desktop.
for n in {1..100} ; do
output=''
expr $n % 3 > /dev/null || output='fizz'
expr $n % 5 > /dev/null || output=$output'buzz'
[ -z $output ] && output=$n
echo $output
done
if [ -z $1 ] ; then
echo {1..100} | parallel -d' ' -k -m -j100 $0 {}
else
output=''
[ $(( $1 % 3 )) -eq 0 ] && output='fizz'
[ $(( $1 % 5 )) -eq 0 ] && output=$output'buzz'
[ -z $output ] && output=$1
echo $output
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment