Notice
Recent Posts
Recent Comments
Link
ยซ   2024/11   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Archives
Today
Total
๊ด€๋ฆฌ ๋ฉ”๋‰ด

Lennon FE

[๋ฐฑ์ค€ 10872๋ฒˆ] ํŒฉํ† ๋ฆฌ์–ผ - ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ(nodejs) ๋ณธ๋ฌธ

๐Ÿ”ฅ Algorithm/Baekjoon

[๋ฐฑ์ค€ 10872๋ฒˆ] ํŒฉํ† ๋ฆฌ์–ผ - ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ(nodejs)

Lennon 2022. 1. 18. 18:55
728x90
๋ฐ˜์‘ํ˜•

https://www.acmicpc.net/step/19

 

์žฌ๊ท€ ๋‹จ๊ณ„

ํ”ผ๋ณด๋‚˜์น˜ ์ˆ˜ ์—ญ์‹œ ๋‹จ์ˆœ for๋ฌธ์œผ๋กœ๋„ ๊ตฌํ•  ์ˆ˜ ์žˆ์ง€๋งŒ, ํ•™์Šต์„ ์œ„ํ•ด ์žฌ๊ท€๋ฅผ ์จ ๋ด…์‹œ๋‹ค.

www.acmicpc.net

const fs = require('fs');
let input = +fs.readFileSync('dev/stdin').toString().trim();

function factorial(num) {
  if (num <= 1) return 1;

  return num * factorial(num - 1);
}

console.log(factorial(input));

๊ฐ„๋‹จํ•˜๊ฒŒ ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ๋‹ค.

 

์žฌ๊ท€๋Š” ์ข…๋ฃŒ์ง€์ ์„ ๊ผญ ๋งŒ๋“ค์–ด์•ผ ์Šคํƒ์˜ค๋ฒ„ํ”Œ๋กœ์šฐ์— ๊ฑธ๋ฆฌ์ง€ ์•Š์Šต๋‹ˆ๋‹ค!

728x90
๋ฐ˜์‘ํ˜•
Comments