Last active
January 4, 2020 12:10
-
-
Save khirotaka/8b33ad0593778afce2a0b1d96bc50b03 to your computer and use it in GitHub Desktop.
Bash で FizzBuzzをするコード。Bashの練習のため
This file contains 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/zsh | |
function fizzbuzz () { | |
if [ $(( $1 % 15 )) -eq 0 ]; then | |
echo FizzBuzz | |
elif [ $(( $1 % 3 )) -eq 0 ]; then | |
echo Fizz | |
elif [ $(( $1 % 5 )) -eq 0 ]; then | |
echo Buzz | |
else | |
echo $1 | |
fi | |
} | |
function main() { | |
for i in $(seq 1 $1); do | |
fizzbuzz $i | |
done | |
} | |
main $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment