title: What's the formula for the sum of integers between n and m?
body: <p>I am looking at this challenge:</p>
  <blockquote>
  <p>The formula to compute the sum from 1 to n is:</p>
  <p>      <strong>total = n * (n + 1) / 2</strong></p>
  <p>Write a function that computes the sum of all values between <strong>n</strong> and <strong>m</strong>, inclusive.</p>
  <p>Is there some way to use that formula, <strong>n</strong>, and <strong>m</strong> to get the answer? Think outside the box... You don't have to come up with a new formula; there's a way to use the existing one to solve it.</p>
  </blockquote>
  <p>I still passed all of the tests by writing this code:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function solution(n, m){
      let numsArr = [];
      for(i=n; i &lt;= m; i++){
          numsArr.push(i);
      }
      let initialValue = 0;
      let sum = numsArr.reduce(
          (previousValue, currentValue) =&gt; previousValue + currentValue,
          initialValue
      );
      return sum
  }
  
  console.log(solution(5,9));</code></pre>
  </div>
  </div>
  </p>
  <p>But how do I solve it using the specified formula?</p>