# [Algorithm/JS] ๋ฐฑ์ค€ 10950๋ฒˆ N ์ฐ๊ธฐ

๐Ÿ”— ๋ฌธ์ œ ๋ฐ”๋กœ๊ฐ€๊ธฐ (opens new window)

# Question

์ž์—ฐ์ˆ˜ N์ด ์ฃผ์–ด์กŒ์„ ๋•Œ, 1๋ถ€ํ„ฐ N๊นŒ์ง€ ํ•œ ์ค„์— ํ•˜๋‚˜์”ฉ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค.

# Input

์ฒซ์งธ ์ค„์— 100,000๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™์€ ์ž์—ฐ์ˆ˜ N์ด ์ฃผ์–ด์ง„๋‹ค.

# Output

์ฒซ์งธ ์ค„๋ถ€ํ„ฐ N๋ฒˆ์งธ ์ค„ ๊นŒ์ง€ ์ฐจ๋ก€๋Œ€๋กœ ์ถœ๋ ฅํ•œ๋‹ค.

# Example

# Input

5
1

# Output

1
2
3
4
5
1
2
3
4
5

# Solution

15552 ๋น ๋ฅธ A+B (opens new window) ๋ฅผ ์‘์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๋ฌธ์ œ๋‹ค. ์•„๋ž˜ ์ฝ”๋“œ์™€ ๊ฐ™์ด for ๋ฌธ ๋‚ด์—์„œ ์ถœ๋ ฅํ•˜๋ฉด ์‹œ๊ฐ„์ด ์ดˆ๊ณผ๋˜์–ด ์‹คํŒจํ•œ๋‹ค.

const input = require('fs').readFileSync('dev/stdin').toString();
for (let i = 1; i <= input; i++) {
  console.log(i);
}
1
2
3
4

# ๋ฌธ์ œํ•ด๊ฒฐ

๋งˆ์ง€๋ง‰์— ํ•œ ๋ฒˆ๋งŒ ์ถœ๋ ฅํ•˜๋Š” ๋ฐฉ์‹๊ณผ ๊ฐœํ–‰๋ฌธ์ž๋ฅผ ํ™œ์šฉํ•ด ๋น ๋ฅธ ์‹œ๊ฐ„์ดˆ๊ณผ ์—†์ด ๋น ๋ฅธ ์ถœ๋ ฅ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

const input = require('fs').readFileSync('dev/stdin').toString();
let answer = '';
for (let i = 1; i <= input; i++) {
  answer += i + '\n';
}
console.log(answer);
1
2
3
4
5
6

๊ฒฐ๊ณผ๋Š” ์„ฑ๊ณต!

Last Updated: 2022. 6. 5. ์˜คํ›„ 3:42:39