gen~ codebox for loop


    Mar 12 2013 | 3:27 pm
    I'm trying to make a for loop with gen but don't know how to do... but maybe there's another way to do than using a for loop...
    here's what I try to do.
    for example if I input 3, I'd like the output to be (1*1) + (2*2) if I input 4, I'd like the output to be (1*1) + (2*2) + (3*3) if I input 5, I'd like the output to be (1*1) + (2*2) + (3*3) +(4*4)
    I'm sure it's simple to do. any idea ?
    Thank you.

    • Mar 12 2013 | 6:30 pm
      I found this, but maybe there's a better way.
    • Mar 12 2013 | 6:38 pm
      Here's another solution
    • Mar 13 2013 | 3:06 am
      nice, it's what I thought could be possible with for. it's more efficient. (0.00028 cpu with my technique, 0.00017 cpu with yours) thank you wesley,