projects
/
fizzbuzz.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
27d8dca
)
シェルスクリプト版を作成
author
j8takagi
<info@j8takagi.net>
Sun, 28 Oct 2012 16:48:40 +0000
(
01:48
+0900)
committer
j8takagi
<info@j8takagi.net>
Sun, 28 Oct 2012 16:48:40 +0000
(
01:48
+0900)
sh/fizzbuzz.sh
[new file with mode: 0755]
patch
|
blob
diff --git a/sh/fizzbuzz.sh
b/sh/fizzbuzz.sh
new file mode 100755
(executable)
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