From 6f09ae747aabf4d4f6bbad3ac047f907ba7044d8 Mon Sep 17 00:00:00 2001 From: j8takagi Date: Mon, 29 Oct 2012 01:48:40 +0900 Subject: [PATCH] =?utf8?q?=E3=82=B7=E3=82=A7=E3=83=AB=E3=82=B9=E3=82=AF?= =?utf8?q?=E3=83=AA=E3=83=97=E3=83=88=E7=89=88=E3=82=92=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- sh/fizzbuzz.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 sh/fizzbuzz.sh diff --git a/sh/fizzbuzz.sh b/sh/fizzbuzz.sh new file mode 100755 index 0000000..2b009c9 --- /dev/null +++ b/sh/fizzbuzz.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +MIN=1 +MAX=100 + +fizzbuzz() { + unset FIZZ; + unset BUZZ; + if test $(expr $1 % 3) -eq 0; then + FIZZ="Fizz"; + fi + if test $(expr $1 % 5) -eq 0; then + BUZZ="Buzz"; + fi + if test -z ${FIZZ} && test -z ${BUZZ}; then + echo $1; + else + echo ${FIZZ}${BUZZ}; + fi +} + +for i in $(seq ${MIN} ${MAX}); do + fizzbuzz $i +done -- 2.18.0