js-mentorship-razvan / javascript

Javascript study notes
GNU General Public License v3.0
22 stars 2 forks source link

Sum of a sequence #440

Closed RazvanBugoi closed 4 years ago

RazvanBugoi commented 4 years ago

https://www.codewars.com/kata/586f6741c66d18c22800010a/train/javascript

RazvanBugoi commented 4 years ago
const sequenceSum = (begin, end, step) => {
 let output = 0;
 if (begin > end) return 0; 
    for (let i=begin; i<=end; i+=step) {
      output += i;
}
  return output;
};