TOPICS
Search

City-Building Sequence


Construction of the city-building sequence

The city-building sequence is the integer sequence obtained by placing buildings at consecutive integer positions along a straight street, choosing each height to be the smallest nonnegative integer equal to the number of earlier rooftops visible from its top. A rooftop is visible when every intervening rooftop lies on or below the line segment joining it to the new rooftop. In particular, collinear rooftops count separately. The visibility rule suggests the descriptive name rooftop visibility sequence. The first building has height 0, and the first terms are 0, 1, 1, 2, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 10, ... (OEIS A400000).

The animation above shows the construction of the first 16 buildings. The candidate building is orange, visible earlier rooftops are blue, and hidden rooftops are gray. Dashed sight lines connect the candidate rooftop to each visible rooftop. Each trial is labeled with its height h, visible-rooftop count, and whether it is rejected (red) or chosen (green). The comparison of the count with h uses the same status color.

CityBuildingSequenceSkylines

The static panels show completed skylines for the first 16, 32, 64, and 128 buildings.

The sequence continues indefinitely, is unbounded, and contains every nonnegative integer (OEIS A400000). To see why a next term always exists, let v(h) be the visible-rooftop count from a candidate height h. This count is nondecreasing as h increases. After at least one building has been placed, v(0)>0, while v(h)<=h for sufficiently large h. The least integer h with v(h)<=h therefore satisfies v(h)=h.

For h=0, 1, 2, ..., let b(h) be the position of the first building of height h. The first terms of this sequence are 1, 2, 4, 8, 24, 128, 648, 1351, 1278, 136, 16, 48, ... (OEIS A399763). On Oct. 27, 2026, Sponaugle (2026) reported that all heights from 0 through 380 had occurred in the first 10^(13) terms, but 381 had not. Thus 381 was the smallest height whose first occurrence remained unlocated in that computation, with b(381)>10^(13).

It is conjectured that the limit superior of the running arithmetic mean is at most 3 (OEIS A400000),

 limsup_(n->infty)1/nsum_(k=1)^na(k)<=3.
OEIS 400000-sequence celebration banner

The sequence won the OEIS 400K celebration contest (OEIS Foundation Inc. 2026a). It was also featured in the front-page banner of the On-Line Encyclopedia of Integer Sequences, reproduced above as it appeared on Oct. 25, 2026 (OEIS Foundation Inc. 2026b).


See also

Greedy Algorithm, Integer Sequence

Explore with Wolfram|Alpha

References

OEIS Foundation Inc. "A400K Winners." 2026a. https://oeis.org/wiki/A400K_Winners.OEIS Foundation Inc. "The On-Line Encyclopedia of Integer Sequences." 2026b. https://oeis.org/. Banner: https://oeis.org/oeis-400k-banner.png. Pegg, E. Jr. "Winners of the OEIS 400K Milestone Contest." Wolfram Community. Oct. 26, 2026. https://community.wolfram.com/t/28423.Sponaugle, J. "Extending A400000 to 10T with Some Visuals." SeqFan mailing list. Oct. 27, 2026. https://groups.google.com/g/seqfan/c/YLh6QcHdARk.Sloane, N. J. A. Sequences A399763 A400000 in "The On-Line Encyclopedia of Integer Sequences."

Cite this as:

Weisstein, Eric W. "City-Building Sequence." From MathWorld--A Wolfram Resource. https://mathworld.wolfram.com/City-BuildingSequence.html

Subject classifications