title: Trying to optimize my code to either remove nested loop or make it more efficient
body: <ul>
  <li><p>A friend of mine takes a sequence of numbers from 1 to n (where n > 0)</p></li>
  <li><p>Within that sequence, he chooses two numbers, a and b</p></li>
  <li><p>He says that the product of a and b should be equal to the sum of all numbers in the sequence, excluding a and b</p></li>
  <li><p>Given a number n, could you tell me the numbers he excluded from the sequence?</p></li>
  </ul>
  
  <p>Have found the solution to this Kata from Code Wars but it times out (After 12 seconds) in the editor when I run it; any ideas as too how I should further optimize the nested for loop and or remove it?</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 removeNb(n) {
    var nArray = [];
    var sum = 0;
    var answersArray = [];
    for (let i = 1; i &lt;= n; i++) {
      nArray.push(n - (n - i));
      sum += i;
    }
    var length = nArray.length;
    for (let i = Math.round(n / 2); i &lt; length; i++) {
      for (let y = Math.round(n / 2); y &lt; length; y++) {
        if (i != y) {
          if (i * y === sum - i - y) {
            answersArray.push([i, y]);
            break;
          }
        }
      }
    }
    return answersArray;
  }
  
  console.log(removeNb(102));</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.as-console-wrapper { max-height: 100% !important; top: 0; }</code></pre>
  </div>
  </div>
  </p>