View Single Post
  #7   Report Post  
Harlan Grove
 
Posts: n/a
Default

Bob Phillips wrote...
If is always 1,2,3....N you can use Gauss's solution

=IF(ISEVEN(A1),(A1/2)*(1+A1),INT(A1/2)*(A1)+A1)

where A1 holds N


Gauss's formula was simpler that Phillips's formula. No need to check
whether A1 is even because either A1 or A1+1 is even. So

=A1*(A1+1)/2

otherwise use

=SUMPRODUCT(--(ROW(INDIRECT(A1&":"&A2))))

where A1 and A2 are first and last numbers

....

Or

=(A2*(A2+1)-(A1-1)*A1)/2