Skip to content

Commit 0b220cc

Browse files
authored
Add files via upload
1 parent adcbb7b commit 0b220cc

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
'use strict';
2+
3+
process.stdin.resume();
4+
process.stdin.setEncoding('utf-8');
5+
6+
let inputString = '';
7+
let currentLine = 0;
8+
9+
process.stdin.on('data', inputStdin => {
10+
inputString += inputStdin;
11+
});
12+
13+
process.stdin.on('end', _ => {
14+
inputString = inputString.trim().split('\n').map(string => {
15+
return string.trim();
16+
});
17+
18+
main();
19+
});
20+
21+
function readLine() {
22+
return inputString[currentLine++];
23+
}
24+
/*
25+
* Create the function factorial here
26+
*/
27+
function factorial(n){
28+
let result = 1;
29+
for (var i=1; i<=n; ++i){
30+
result *=i;
31+
}
32+
return result;
33+
}
34+
35+
function main() {
36+
const n = +(readLine());
37+
38+
console.log(factorial(n));
39+
}

0 commit comments

Comments
 (0)