Last active
April 5, 2017 15:05
-
-
Save anyheck/fdad5d88af38f164b28f2445fba81e77 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# "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