Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Sum All Numbers in a Range

const sumAll = arr => {
   let maxNumber = Math.max(...arr)
   let minNumber = Math.min(...arr)
   let numbersArray = []

   for(let i = minNumber; i <= maxNumber; i++){
     numbersArray.push(i)
   }
   return numbersArray.reduce((acc, cur) => acc + cur, 0)
}

sumAll([1, 4]);

// With love @kouqhar
Source by www.linkedin.com #
 
PREVIOUS NEXT
Tagged: #Sum #All #Numbers #Range
ADD COMMENT
Topic
Name
9+7 =