๐Ÿค ์€์ง€log ๐Ÿค

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค:Javascript] x๋งŒํผ ๊ฐ„๊ฒฉ์ด ์žˆ๋Š” n๊ฐœ์˜ ์ˆซ์ž ๋ณธ๋ฌธ

๐ŸŒˆ ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค:Javascript] x๋งŒํผ ๊ฐ„๊ฒฉ์ด ์žˆ๋Š” n๊ฐœ์˜ ์ˆซ์ž

Eun_zii 2022. 9. 26. 16:27

ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค Lv.1

- x๋งŒํผ ๊ฐ„๊ฒฉ์ด ์žˆ๋Š” n๊ฐœ์˜ ์ˆซ์ž

๐Ÿ’š ๋ฌธ์ œ์„ค๋ช…

  • ํ•จ์ˆ˜ solution์€ ์ •์ˆ˜ x์™€ ์ž์—ฐ์ˆ˜ n์„ ์ž…๋ ฅ๋ฐ›์•„, x๋ถ€ํ„ฐ ์‹œ์ž‘ํ•ด x์”ฉ ์ฆ๊ฐ€ํ•˜๋Š” ์ˆซ์ž๋ฅผ n๊ฐœ ์ง€๋‹ˆ๋Š” ๋ฆฌ์ŠคํŠธ๋ฅผ ๋ฆฌํ„ดํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์Œ ์ œํ•œ ์กฐ๊ฑด์„ ๋ณด๊ณ , ์กฐ๊ฑด์„ ๋งŒ์กฑํ•˜๋Š” ํ•จ์ˆ˜, solution์„ ์™„์„ฑํ•ด์ฃผ์„ธ์š”.

 

๐Ÿ’š ์ œํ•œ์กฐ๊ฑด

  • x๋Š” -10000000 ์ด์ƒ, 10000000 ์ดํ•˜์ธ ์ •์ˆ˜์ž…๋‹ˆ๋‹ค.
    n์€ 1000 ์ดํ•˜์ธ ์ž์—ฐ์ˆ˜์ž…๋‹ˆ๋‹ค.

๐Ÿ’š ๋ฌธ์ œ

function solution(x, n) {
    }
    var answer = [];
    return answer;

 

 

๐Ÿ’š ํ’€์ด

function solution(x, n) {
    var answer = [];
for (i=1; i<=n; i++){
    answer.push(x*i);
}
    return answer;
}
728x90