Created
May 24, 2012 02:02
-
-
Save usagi/2779019 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
| #!/bin/sh | |
| function main(){ | |
| configure | |
| run | |
| } | |
| function configure(){ | |
| echo 'いくつから?' | |
| read range_begin | |
| echo 'いくつまで?' | |
| read range_end | |
| } | |
| function run(){ | |
| sequence=`seq $range_begin $range_end` | |
| for n in $sequence | |
| do | |
| let n_mod_3=n%3 | |
| let n_mod_5=n%5 | |
| if [ $n_mod_3 -eq 0 ] | |
| then | |
| echo -n 'Fizz!' | |
| fi | |
| if [ $n_mod_5 -eq 0 ] | |
| then | |
| echo -n 'Buzz!' | |
| elif ! [ $n_mod_3 -eq 0 ] | |
| then | |
| echo -n $n | |
| fi | |
| echo | |
| done | |
| } | |
| main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment