Skip to content

Instantly share code, notes, and snippets.

@usagi
Created May 24, 2012 02:02
Show Gist options
  • Select an option

  • Save usagi/2779019 to your computer and use it in GitHub Desktop.

Select an option

Save usagi/2779019 to your computer and use it in GitHub Desktop.
#!/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