projects
/
fizzbuzz.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
387bd8e
)
Spider Monkey版を追加
author
j8takagi
<info@j8takagi.net>
Sun, 28 Oct 2012 14:04:12 +0000
(23:04 +0900)
committer
j8takagi
<info@j8takagi.net>
Sun, 28 Oct 2012 14:04:12 +0000
(23:04 +0900)
javascript/fizzbuzz2.js
[new file with mode: 0644]
patch
|
blob
diff --git a/javascript/fizzbuzz2.js
b/javascript/fizzbuzz2.js
new file mode 100644
(file)
index 0000000..
257635e
--- /dev/null
+++ b/
javascript/fizzbuzz2.js
@@ -0,0
+1,22
@@
+#!/usr/local/bin/js
+min = 1;
+max = 100;
+
+for(i = min; i <= max; i++) {
+ print(fizzbuzz(i));
+}
+
+function fizzbuzz(n) {
+ fizz = (n % 3 == 0);
+ buzz = (n % 5 == 0);
+ if(fizz && buzz) {
+ fb = "FizzBuzz";
+ } else if(fizz) {
+ fb = "Fizz";
+ } else if(buzz) {
+ fb = "Buzz";
+ } else {
+ fb = n;
+ }
+ return fb;
+}