aboutsummaryrefslogtreecommitdiff
path: root/challenge-252/zapwai/javascript/ch-2.js
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-252/zapwai/javascript/ch-2.js')
-rw-r--r--challenge-252/zapwai/javascript/ch-2.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/challenge-252/zapwai/javascript/ch-2.js b/challenge-252/zapwai/javascript/ch-2.js
new file mode 100644
index 0000000000..1fe5b40823
--- /dev/null
+++ b/challenge-252/zapwai/javascript/ch-2.js
@@ -0,0 +1,17 @@
+let inputs = [5, 3, 1];
+for (let inp of inputs) {
+ proc(inp);
+}
+function proc(n) {
+ let list = [];
+ if (n % 2 == 1) {
+ list.push(0);
+ }
+ let k = parseInt(n / 2);
+ for (let i = 0; i < k; i++) {
+ list.push(-1 * (i+1));
+ list.push(i+1);
+ }
+ console.log("Input:", n);
+ console.log("Output:", list);
+}