# [Algorithm/JS] ๋ฐฑ์ค€ 2439๋ฒˆ ๋ณ„์ฐ๊ธฐ-2

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

# Question

์ฒซ์งธ ์ค„์—๋Š” ๋ณ„ 1๊ฐœ, ๋‘˜์งธ ์ค„์—๋Š” ๋ณ„ 2๊ฐœ, N๋ฒˆ์งธ ์ค„์—๋Š” ๋ณ„ N๊ฐœ๋ฅผ ์ฐ๋Š” ๋ฌธ์ œ

# Input

์ฒซ์งธ ์ค„์— N(1 โ‰ค N โ‰ค 100)์ด ์ฃผ์–ด์ง„๋‹ค.

# Output

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

# Example

# Input

5
1

# Output

    *
   **
  ***
 ****
*****
1
2
3
4
5

# Solution

const input = require('fs').readFileSync('dev/stdin').toString();
const num = Number(input);
let result = '';
for (let i = 0; i < num; i++) {
  for (let j = 0; j < num - i - 1; j++) {
    result += ' ';
  }
  for (let k = 0; k <= i; k++) {
    result += '*';
  }
  result += '\n';
}
console.log(result);
1
2
3
4
5
6
7
8
9
10
11
12
13
Last Updated: 2022. 6. 5. ์˜คํ›„ 3:42:39