We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6ae5776 commit 5fe5381Copy full SHA for 5fe5381
src/First_Factorial.js
@@ -0,0 +1,26 @@
1
+// Description: For this challenge you will be determining the factorial for a
2
+// given number.
3
+
4
+// Q. Have the function FirstFactorial(num) take the num parameter being passed
5
+// and return the factorial of it. For example: if num = 4, then your
6
+// program should return (4 * 3 * 2 * 1) = 24. For the test cases, the range
7
+// will be between 1 and 18 and the input will always be an integer.
8
9
+// Examples
10
+// Input: 4
11
+// Output: 24
12
13
+// Input: 8
14
+// Output: 40320
15
16
+const firstFactorial = num => {
17
+ let factorial = 1;
18
19
+ for (let i = 1; i <= num; i++) {
20
+ factorial = factorial * i;
21
+ }
22
23
+ return factorial;
24
+};
25
26
+console.log(firstFactorial(4));
0 commit comments