You're reading: Travels in a Mathematical World

Building the 400,000th OEIS Sequence: a MathsJam activity

On Saturday night after dinner at the MathsJam weekend, delegates can take part in a variety of activities called Saturday evening tables. At the 2026 event I ran a table ‘Making OEIS Sequence A400000: The city-building sequence’.

The city-building sequence is defined such that each term is the height h of the shortest building which can see exactly h earlier buildings. The weekend before MathsJam my son and I had a go at trying to understand what this means using little cubes, and when these got quite wobbly and less accurate, by drawing on graph paper.

Wooden blocks standing in towers.
sequence drawn as squares drawn on graph paper, with a child's hands using a ruler to check line of sight

I found this quite a nice, meditative activity, the perfect mathematical-but-calm thing to do a the end of a day of lightning talks and maths chat. So I proposed it as a Saturday night table.

Top down view of a table containing graph paper, glasses, pens and small cubes. Hands are arranging cubes into towers.

The sequence starts with a zero-height building, and we must be happy to consider a zero-height building to be both there and visible. Then from the second position, we can see the zero-height building (yes we can), so building two has height 1 – it can see one previous building. The sequence so far goes: 0, 1.

In the third position we cannot put a building of height zero because it can definitely see the building of height 1 in position two. If we place a building of height 1 it can see the height 1 building next to it but that building blocks it from seeing the zero-height building. So the third position also has a building of height 1 and we have 0, 1, 1.

At this point it’s worth considering what we mean by “see”. I was thinking of this as if you are a tiny person on top of the cube block, you can walk back and forth on the top and see any distance in line of sight. Also a building can see any number of buildings of the same height in line with it.

So for position four, if we place a building of height 1 it is the same height as the two previous buildings and can therefore see them. If we place a building of height 2, it can see the two buildings of height 1 but by line of sight it cannot see the building of height 0. So the sequence goes: 0, 1, 1, 2.

Four terms of the sequence, with a line of sight from the top of building 4 showing it cannot see building 1.

After the building of height 2 we have a building of height 1 – it can only see the 2-high building and not past it. Will a tall building always be followed by a building of height 1?

Some MathsJammers came up with a metric based on the number of squares moved across and up to judge line of sight, and one started writing code to generate more terms. Others were happy with either line of sight using a rule.

After not too long there is a surprise – spoiled in the picture below. I found it useful to have the list of terms to hand to consult, to help when I was unsure whether we had correctly interpreted the rules. One issue we resolved this way was when we realised your tiny person could stand at the back of the roof and look up.

The sequence won a contest to celebrate the 400,000th sequence in the The On-Line Encyclopedia of Integer Sequences (OEIS). Over one hundred sequences were nominated, and a selection committee chose one to be renumbered as A400000. The contest page lists some runners up and honourable mentions.

There are some interesting questions discussed on the OEIS page. Is the sequence infinite? If so, does every number eventually appear? There are various patterns that reappear at different scales, do these last indefinitely?

My son and I went as far as two pieces of graph paper before stopping, which I think gave us a little insight into one of the structures that emerges. Most people at MathsJam got to the first big tower and some got to the second. Grab some cubes or a pen and paper and see how far you get!

29 terms of the sequence, both as towers of blocks and drawn on paper with lines of sight drawn.

You must be logged in to post a comment.