From 3d5c6acadc3a9c8ad1a0444ca8586ef327ba940c Mon Sep 17 00:00:00 2001 From: luckylooky2 Date: Sat, 7 Sep 2024 18:35:33 +0900 Subject: [PATCH] 09.07: math(Pyramids) --- baekjoon/5341.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 baekjoon/5341.js diff --git a/baekjoon/5341.js b/baekjoon/5341.js new file mode 100644 index 0000000..6ae602f --- /dev/null +++ b/baekjoon/5341.js @@ -0,0 +1,16 @@ +// Pyramids : 수학 +const input = require("fs") + .readFileSync(0, "utf-8") + .trim() + .split("\n") + .map((v) => +v); +const answer = []; + +for (const elem of input) { + if (elem === 0) { + break; + } + answer.push((elem * (elem + 1)) / 2); +} + +console.log(answer.join("\n"));