Skip to content

Instantly share code, notes, and snippets.

@anyheck
Last active April 5, 2017 15:05
Show Gist options
  • Save anyheck/fdad5d88af38f164b28f2445fba81e77 to your computer and use it in GitHub Desktop.
Save anyheck/fdad5d88af38f164b28f2445fba81e77 to your computer and use it in GitHub Desktop.
# "Write a program that prints the numbers from 1 to 100.
# But for multiples of three print “Fizz”
# instead of the number and for the multiples of five print “Buzz”.
# For numbers which are multiples of both three and five print “FizzBuzz”."
for i in {1..100} ; do
fizzed=0
buzzed=0
if ! (( $i % 3 ))
then
printf fizz
fizzed=1
fi
if ! (( $i % 5 ))
then
printf buzz
buzzed=1
fi
if ! (( $fizzed + $buzzed ))
then
printf "$i"
fi
printf "\n"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment