The Computer Oracle

Can Excel produce a strange but logical sequence of numbers?

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Romantic Lands Beckon

--

Chapters
00:00 Can Excel Produce A Strange But Logical Sequence Of Numbers?
00:32 Accepted Answer Score 38
01:03 Answer 2 Score 13
01:14 Answer 3 Score 56
01:38 Answer 4 Score 9
02:22 Thank you

--

Full question
https://superuser.com/questions/1196354/...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#microsoftexcel

#avk47



ANSWER 1

Score 56


Excel supports arithmetic patterns with step size >1 Fill in the first 3 values, and then use a pattern from there down

  1. 14
  2. 16
  3. 17
  4. =A1+5

and then copy that down. I.e. A5 becomes =A2+5 which is indeed 21.




ACCEPTED ANSWER

Score 38


Excel only recognizes arithmetic patterns.

In your case, you can define a formula and fill it to the needed rows.

=A1 + IF(MOD(ROW(), 3) = 0, 1, 2)

Change A1 to the cell where your sequence starts.

In this screen shot below, A1 has the value 14. In A2 I entered this formula

=A1 + IF(MOD(ROW(),3)=0,1,2)

And copied it down

enter image description here




ANSWER 3

Score 13


Assuming you start at row 1, it's =ROUND((ROW()*5+37)/3,0)

For every 3 rows, you add 5, hence 5/3. The 37 is to get the starting value right (row 1 => value 14). ROUND to two digits to see how it works.




ANSWER 4

Score 9


I really like the intuition behind the already posted answers but it seems everyone is overlooking the simplest solution built into excel.

  • Just type 14 in cell A1

  • in A2 type =A1 + 2

  • in A3 type =A2 + 1

  • in A4 type =A3 + 2

  • select cells A2, A3 and A4 and drag the fill handle in the bottom right corner to the desired point. Excel will indeed repeat the formulas as typed.

Edit: Just to add, although the OP's question is arithmetic in nature and can be tackled with elegant mathematical solutions, if someone comes across this with any other non-mathematical formulas they want to repeat in this fashion, any conditional math would just clutter and slow down the sheet.