forked from TheNewStyles/hackerrank-solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay1.Functions.js
More file actions
41 lines (25 loc) · 756 Bytes
/
Day1.Functions.js
File metadata and controls
41 lines (25 loc) · 756 Bytes
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
31
32
33
34
35
36
37
38
39
40
41
// Objective
// Today, we're discussing JavaScript functions. Check out the attached tutorial for more details.
// Task
// Implement a function named factorial that has one parameter: an integer, . It must return the value of (i.e., factorial).
// Input Format
// Locked stub code in the editor reads a single integer, , from stdin and passes it to a function named factorial.
// Constraints
// Output Format
// The function must return the value of .
// Sample Input 0
// 4
// Sample Output 0
// 24
// Explanation 0
// We return the value of .
/*
* Create the function factorial here
*/
var factorial = function (input) {
var temp = input;
for (var i=input-1; i>0; i--) {
temp *= i;
}
return temp;
}