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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top