๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

ํ”„์—” ๊ณต๋ถ€/๐Ÿซง ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๊ณต๋ถ€

[๋ฐฑ์ค€/Node.js] 8393๋ฒˆ ํ’€์ด || JavaScript

728x90
let input = require('fs').readFileSync('/dev/stdin').toString().split(" ");
let loop = +input[0];

console.log(loop * (loop + 1) / 2);
const input = require('fs').readFileSync('./input.txt').toString();
let loop = Number(input[0]);

let sum = 0;
for (i = 0; i <= loop; i++) {
    sum += i;
}
console.log(sum);

์ฒ˜์Œ์— ๋กœ์ง์€ ์•„๋ž˜์ฒ˜๋Ÿผ ํ–ˆ์—ˆ๋‹ค.

VS์—์„œ๋Š” ์ •์ƒ์ ์œผ๋กœ ๊ฐ’์ด ์ถœ๋ ฅ๋˜๋Š”๋ฐ, ์ฑ„์ ์—์„œ๋Š” ๊ณ„์† ํ‹€๋ ธ๋‹ค๊ณ  ํ•ด์„œ ๋ญ”๊ฐ€ ํ•˜๊ณ  ๋ดค๋‹ค.

๊ฒฐ๊ตญ const input = require('fs').readFileSync('./input.txt').toString().split(" ");

๐Ÿคฆ‍โ™€๏ธsplit(" ")  ์„ ๋ถ™์ด๊ณ  ๋‚˜๋‹ˆ ๋งž์•˜๋‹ค๊ณ  ๋‚˜์™”๋‹ค... ๋‹ต๋‹ต..

 

 

728x90
๋ฐ˜์‘ํ˜•