title: How to get sum with for loop
body: <p>I need to solve for the sum of <code>(10^2 + 10^3) * 99</code>, the sum will be <code>total = (1100+1100+1100...(99 times))</code>. I know most people don't like loops but I need to solve for this using a for loop. Here is what I have so far... </p>
  
  <pre><code>prob1 &lt;- function(n){  
    total &lt;- 1100
    for(i in 2:99) 
      total[i] &lt;- sum(i^2 + i^3)  
    return(total)
  }
  </code></pre>
  
  <p>This is what I get</p>
  
  <pre><code>[1]   1100     12     36     80    150    252    392    576    810   1100   1452   1872   2366   2940   3600
  [16]   4352   5202   6156   7220   8400   9702  11132  12696  14400  16250  18252  20412  22736  25230  27900
  [31]  30752  33792  37026  40460  44100  47952  52022  56316  60840  65600  70602  75852  81356  87120  93150
  [46]  99452 106032 112896 120050 127500 135252 143312 151686 160380 169400 178752 188442 198476 208860 219600
  [61] 230702 242172 254016 266240 278850 291852 305252 319056 333270 347900 362952 378432 394346 410700 427500
  [76] 444752 462462 480636 499280 518400 538002 558092 578676 599760 621350 643452 666072 689216 712890 737100
  [91] 761852 787152 813006 839420 866400 893952 922082 950796 980100
  </code></pre>
  
  <p>How can I get it to add correctly and return just the total as integer instead of an array? 
  The total should be <code>108900</code> (I believe)</p>