We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3af1666 commit c4c3045Copy full SHA for c4c3045
Functions.js
@@ -0,0 +1,40 @@
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
+ {
29
+ if(n==0)
30
+ return 1;
31
+ else
32
+ return n*factorial(n-1);
33
+ }
34
35
36
+function main() {
37
+ const n = +(readLine());
38
39
+ console.log(factorial(n));
40
0 commit comments