title: When loop run billion times in Javascript
body: <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 add1(n) {
        let sum = 0;
        for(let i = 1; i &lt;= n; i++) {
          sum = sum + i;
        }
        console.log(sum);
      }
      function add2(n) {
        sum = n * (n + 1) / 2;
        console.log(sum);
       }
       add1(134217730);
       add2(134217730);</code></pre>
  </div>
  </div>
  </p>
  <p>When I ran this code with the value of <code>134217729</code> fun <code>add1()</code> working fine. after this value it print different result.</p>
  <p>and when I ran this concept in C, most of the time both functions give same result.</p>
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;conio.h&gt;
  
  typedef unsigned long long int ulli;
  
  ulli add1(ulli num) {
      ulli i,total=0;
      for(i = 1; i &lt;= num; i++) {
          total += i;
      }
      printf(&quot;Result of add1 is %llu\n&quot;, total);
      return total;
  }
  
  ulli add2(ulli num) {
      ulli total;
      total = (ulli)(num * (num + 1) /2.0);
      printf(&quot;Result of add2 is %llu\n&quot;, total);
      return total;
  }
  
  
  int main() {
      ulli num;
      
      printf(&quot;Enter A Number&quot;);
      scanf(&quot;%llu&quot;, &amp;num);
      printf(&quot;Number is %llu\n&quot;,num);
      
      add1(num);
      add2(num);
  
      return 0;
  }
  </code></pre>
  <p>I have no Idea why this kind of strange output I have seen.
  is there any problem in my code.
  or this is internal behaviour of V8 engine.
  or something else.</p>