how to add consecutive numbers?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

what function will i use to add consecutive numbers starting from 1 to (X)?

example: X = 10
y = 1 + 2 + 3 + 4 + 5 + . . . . . . + 10
y= 55

y = (what function)(x)
 
I don't know of any particular function, but there is a formula

y = x * (x + 1) / 2

In general, for consecutive whole numbers,

y = (b + a) * (b - a + 1) / 2

where a and b are the lowest and highest numbers respectively.
 
Back
Top