title: JavaScript math, loops inside loops
body: <p>I've a starting number, so that number must be multiplied, only at starting cycle, by a factor, then the results multiplied X times for another factor, then the cycle must be multiplied for Y times, and at the end I need to have the total sum ... I think that is better to see the numbers to see what I need to have</p>
  
  <p>For example if I start with the number 10, this is the right progression:</p>
  
  <ul>
  <li>10</li>
  <li>50 (10*5)</li>
  <li>60 (50*1.2)</li>
  <li>72 (60*1.2)</li>
  <li>86.4 (72*1.2)</li>
  <li>103.68 (86.4*1.2)</li>
  <li>124.416 (103.68*1.2)</li>
  </ul>
  
  <p>For me the first 6 is the inner cycle from now on, I need to replicate the proces but I had to use the last value, 124.416 multiplied by 5 then for 1.2 again, so</p>
  
  <ul>
  <li>622.08 (124.416*5)</li>
  <li>746.496 (622.08*1.2)</li>
  <li>895.7952 (746.496*1.2)</li>
  <li>1074.95424 (895.7952*1.2)</li>
  <li>1289.94509 (1074.95424*1.2)</li>
  <li>1547.93411 (1289.94509*1.2)</li>
  <li>1857.52093 (1547.93411*1.2)</li>
  </ul>
  
  <p>and so on ...</p>
  
  <p>And at the end I need to sum all this intermediate results, 10 + 50 + 60 + 72 ...</p>
  
  <p>I tried to do this, but is not what I need, the inner cycle works like exposed but when I add the outter cycle everythings goes wrong!</p>
  
  <pre><code>outtercycle = 5;
  base = 10;
  mult1 = 5;
  mult2 = 1.2;
  innercycle = 6;
  
  aaa = 0;
  number = 0;
  
  function test()
  {
      for (j = 0; j &lt; outtercycle; j++) {
          aaa = base * mult1;
          number += aaa;
          for (i = 0; i &lt; (innercycle - 1); i++) {
              aaa *= mult2;
              number += aaa;
          }
      }
  return number + base;
  }
  
  base = test();
  </code></pre>
  
  <p>On the code I need to have 5 outter cycles, but I'm testing it only on 2, It's the same I think, when this works, works with any variable values, right?</p>
  
  <p>Any idea about this little problem?</p>