Last active
November 25, 2022 11:15
-
-
Save earlonrails/1339884 to your computer and use it in GitHub Desktop.
Fizz Buzz in bash! Hooray!
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 | |
x=1 | |
while [ $x -le 100 ] | |
do | |
if [[ 0 -eq "($x%3) + ($x%5)" ]] | |
then | |
# Check if divide by 3 & 5 # | |
echo "fizz buzz" | |
elif [[ 0 -eq "($x%5)" ]] | |
then | |
# Check if divide by 5 # | |
echo "buzz" | |
elif [[ 0 -eq "($x%3)" ]] | |
then | |
# Check if divide by 3 # | |
echo "fizz" | |
else | |
echo "$x" | |
fi | |
x=$(( $x + 1 )) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment