Created
January 5, 2017 15:00
-
-
Save stevenwilkin/20c9a7f3c5e4a554aaebf7690df2d177 to your computer and use it in GitHub Desktop.
FizzBuzz in Bash
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
#!/bin/bash | |
set -u | |
for i in $(seq 1 20); do | |
divisible_by_three=$(expr $i % 3) | |
divisible_by_five=$(expr $i % 5) | |
[ $divisible_by_three -eq 0 ] && [ $divisible_by_five -eq 0 ] && echo "Fizz Buzz" && continue | |
[ $divisible_by_three -eq 0 ] && echo "Fizz" && continue | |
[ $divisible_by_five -eq 0 ] && echo "Buzz" && continue | |
echo $i | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment