Formula in Excel or Numbers to generate a series of numbers

0

In my spreadsheet I have two numbers, start_number and nr_iterations. I'm looking for an formula that returns a series of numbers starting with start_number - 1 and nr_iterations long (each following item with the value of one lower).

So like this:

(nr_iterations, start_number) => [my_number_serie]  
(0, 1) => []  
(1, 3) => [2]  
(2, 5) => [4, 3]  
(3, 7) => [6, 5, 4]  
(4, 9) => [8, 7, 6, 5]  

Basically, start_number is also calculated, but probably is not too important:

start_number = 1 + nr_iterations*2

I'm actually interested in the SUM of this serie numbers, if that's of any help.

doekman

Posted 2019-01-05T15:54:01.477

Reputation: 281

Answers

1

Enter the following formulae in the cells indicated:-

[A1] =ROW(A1)-1
[B1] =2*A1+1
[C1] =B1*(B1-1)/2-A1*(A1+1)/2

Then copy A1:C1 down as many rows as you need:

Number Sequence

Notes:-

  • If you want column headers and you need your data to start at a different row, then change the offset in the first cell (eg to start from row 3, A3 should be =ROW(A3)-3).
  • The sum in column C is derived using the formula that the sum of the first n integers is n*(n+1)/2.
  • I tested using LibreOffice, but Excel will be compatible.

AFH

Posted 2019-01-05T15:54:01.477

Reputation: 15 470

That's it. And thanks for the explanation how to sum up the first n integer. It can actually be rewritten to [C1] =(3*A1*A1+A1)/2 so you don't need [B1], but your example is more clear. – doekman – 2019-01-05T20:02:01.263

I did realise that, but I left it as I did so as to show the logic of the calculation, as well as allowing for different upper bounds to the range. – AFH – 2019-01-05T20:35:26.993

Hmm, I don't get it completely. If we break the formula from C1 into [D1] = B1*(B1-1)/2 and [E1] =A1*(A1+1)/2, so we can redefine [C1] = D1-E1. In this, E1 is SUM(1..A1), but what is D1? – doekman – 2019-01-06T17:37:19.187

D1 is SUM(1..B1)-B1, ie SUM(1..(B1-1)). Another way to see the formula is to substitute B1-1 for n in *n(n+1)/2**. – AFH – 2019-01-06T17:56:45.827