Duration: You should not spend more than 2 hours on this problem.
Task: Provide 3 unique implementations of the following function.
Input: n
- any integer from 0
to Number.MAX_SAFE_INTEGER
.
Output: return
- summation to n
, i.e. sum_to_n(5) === 1 + 2 + 3 + 4 + 5 === 15.
var sum_to_n = function(n) {
// your code here
};
Please submit your solution using the files provided in this folder
solution_a.js
solution_b.js
solution_c.js