Golomb Sequence Calculator

Sequences

Golomb sequence value a(100)21
previous term a(n - 1)21
next term a(n + 1)21
times the value n appears as a term21
How this was calculated
  1. The Golomb sequence is self-describing: a(1) = 1 and the recurrence a(n + 1) = 1 + a(n + 1 - a(a(n))) makes each value repeat exactly as often as the sequence itself dictates.
  2. Running the recurrence up to n = 100 gives a(100) = 21.
  3. Self-describing means the value k appears exactly a(k) times as a term - the sequence is its own run-length table.
  4. The terms grow smoothly despite the tangled recurrence, at a rate close to a constant times n^0.381, with the constant built from the golden ratio.

Read this list aloud as instructions: 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6. One 1. Two 2s. Two 3s. Three 4s. Three 5s. Four 6s. The counts of each value are given by the sequence itself - the value k appears exactly a(k) times. That is the Golomb sequence: a sequence that is its own run-length table, a fixed point of self-description.

Solomon Golomb defined it through a tangled little recurrence, a(n + 1) = 1 + a(n + 1 - a(a(n))), and the miracle is that the output of that recurrence is exactly the self-describing list. The sequence grows smoothly despite the tangle: a(100) = 21 and a(1000) = 86.

This calculator evaluates a(n) by generating the recurrence up to n, or lists the first terms so you can check the self-description with your own eyes.

Worked examples

Golomb a(100)

(0 - the value a(n) · 100)

Golomb sequence value a(100)21
previous term a(n - 1)21
next term a(n + 1)21
times the value n appears as a term21

Golomb a(1000)

(0 - the value a(n) · 1000)

Golomb sequence value a(1,000)86
previous term a(n - 1)86
next term a(n + 1)86
times the value n appears as a term86

First 15 terms

(1 - the first n terms · 15)

first 15 terms of the Golomb sequence1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6
largest term shown6
last term shown, a(n)6
distinct values shown6

A sequence that describes itself

Most sequences describe something else - primes, powers, counts of partitions. The Golomb sequence describes itself. Take its terms as run lengths: the sequence says there is one 1, then two 2s, then two 3s, then three 4s - and if you count the actual runs in the sequence, those are exactly the runs you find. The statement a(k) = (number of times k appears) is not an extra property; it is the definition the recurrence secretly encodes.

A subtle point rewards care: the value 4 appears exactly 3 times, at positions 6, 7 and 8, because a(4) = 3. It is tempting to misread early terms - the value 4 does not appear 4 times, and the sequence would break if it did. The calculator's value mode makes the property checkable: for the n you enter, it reports a(n), and that same number is the count of occurrences of the value n in the full sequence.

  • Self-describing: value k occurs exactly a(k) times
  • Starts 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6
  • Non-decreasing: runs of equal values, then a step
  • Named for Solomon W. Golomb

The recurrence

Golomb's recurrence is a knot: to compute a(n + 1) you need a(a(n)), the sequence applied to its own output. Yet it unwinds without circularity, because every index it consults is smaller than n + 1. Starting from a(1) = 1, the terms generate in order, each new term a small look-back into the table built so far. The calculator generates exactly this way, keeping the full table - which is why value mode and list mode are the same computation at different depths.

There is no closed form. But the recurrence has a constructive reading: a(n + 1) is one more than the term a certain distance back, and that distance is governed by the sequence's own current value. The self-reference is precisely calibrated so that the run-length property emerges - change the recurrence slightly and the miracle evaporates.

  • a(1) = 1 seeds the sequence
  • a(n + 1) = 1 + a(n + 1 - a(a(n)))
  • Nested self-reference: a(a(n)) reaches back twice
  • Generation is sequential - term n needs the earlier terms

Values at round numbers

At n = 100 the sequence has only reached a(100) = 21 - growth is slow, slower than any root-like power for long stretches, and the runs lengthen gradually. At n = 1000, a(1000) = 86. The calculator reports the neighbouring terms too: a(99) and a(101) around a(100), typically equal to it, because runs are long compared with single steps.

The first 15 terms show the whole personality: 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6. Six distinct values appear, the largest term is 6, and the run of 6s is four long - positions 12 to 15 - because a(6) = 4. Every feature of the list can be audited against the sequence itself, which is the entire point.

  • a(100) = 21 and a(1000) = 86
  • First 15 terms: 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6
  • The value 6 runs four times, positions 12 to 15, since a(6) = 4
  • Distinct values in the first 15 terms: 6

How fast it grows

For all its self-reference, the Golomb sequence is tame. It is non-decreasing, it increases by at most 1 at a time in effect, and asymptotically a(n) behaves like a constant times n^0.381, where the exponent and constant are built from the golden ratio. The run lengths grow, but predictably - the sequence is a fixed point, not a chaotic system.

The contrast with its famous relative is instructive. Hofstadter's Q sequence uses a similar self-referential shape and produces chaos - terms lurching around n / 2 with no closed form and no proven long-term behaviour. Golomb's recurrence, differing only in structure, produces perfect order. This site has calculators for both, and running them side by side is the fastest way to feel how thin the line between order and chaos in recurrences can be.

  • Growth near a constant times n^0.381
  • The constant involves the golden ratio
  • Smooth despite the recurrence - no chaos
  • Contrast with Hofstadter's Q sequence, its wild relative

Variations and relatives

The Golomb sequence belongs to a family of self-referential constructions. Its closest relatives are the 'Recaman-like' run-length sequences and the self-generating lists where a sequence is defined to be a fixed point of some transformation. Golomb's is the purest: the transformation is run-length encoding itself, and the sequence is (up to the seed) the unique non-decreasing fixed point. Asking 'which sequences describe themselves' leads here almost immediately.

There is also a practical echo in data compression and coding, Golomb's own field: Solomon Golomb is the same name behind Golomb codes, a family of entropy codes for geometric distributions used in image and audio compression. The self-describing sequence and the codes share a design aesthetic - let the data's own statistics dictate the structure - though they are mathematically independent creations.

For computation, the recurrence's appetite is linear: generating a(n) needs the table of all previous terms, since a(a(n)) can reach far back. The calculator caps its modes accordingly and generates the table once per query. Mathematicians have pushed the sequence to billions of terms with optimised generators, verifying the smooth asymptotic growth far beyond what this page needs - a(n) tracking its n^0.381 law with slowly shrinking relative error.

  • Unique non-decreasing run-length fixed point
  • Same inventor as Golomb codes in compression
  • Generation needs the full table of earlier terms
  • Verified to billions of terms in the literature

Worked checks and pitfalls

The self-describing property can be audited by hand on the calculator's list output. Take the first 15 terms: 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6. Count the values: one 1 (a(1) = 1, correct), two 2s (a(2) = 2, correct), two 3s (a(3) = 2, correct), three 4s (a(4) = 3, correct), three 5s (a(5) = 3, correct), four 6s (a(6) = 4, correct). Every count so far is dictated by the sequence itself - the audit closes with no outside information.

The standard pitfall is assuming the value k appears k times, or appears a(k) times 'starting later'. It appears exactly a(k) times in the whole infinite sequence, full stop - for 4, that is 3 appearances total, all of them early (positions 6 to 8), never a fourth. A second pitfall is the recurrence's indexing: it is stated here as a(n + 1) = 1 + a(n + 1 - a(a(n))) with a(1) = 1; shifted versions in some sources generate the same sequence from a different seed line, so verify against the terms 1, 2, 2, 3, 3, 4 before trusting any implementation - including, of course, this one.

  • Hand-audit: counts in the first 15 terms match a(k)
  • Value k appears exactly a(k) times in total
  • 4 appears 3 times, at positions 6 to 8, never again
  • Verify implementations against 1, 2, 2, 3, 3, 4

A note on the growth constant

The asymptotic a(n) ~ C n^0.381... hides a pretty constant: the exponent is log_phi-related - precisely, a(n) grows like a constant times n^(1 - 1/phi^2)-style expressions in the literature, with phi the golden ratio - reflecting that the run-length structure settles into a self-similar regime governed by the same fixed-point logic as the sequence itself. For calculator purposes the operative facts are the anchors: a(100) = 21 and a(1000) = 86, and the steady sub-linear climb between and beyond them. Any implementation that produces a(1000) materially different from 86 has a bug, whatever its internal logic claims.

  • Growth exponent is golden-ratio flavoured
  • Anchors: a(100) = 21, a(1000) = 86
  • Sub-linear, steady, no surprises

FAQs

What is the Golomb sequence?

The self-describing sequence where each value k appears exactly a(k) times as a term. It starts 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6.

What is a(100)?

21.

What is a(1000)?

86.

How many times does 4 appear?

Exactly 3 times, at positions 6, 7 and 8 - because a(4) = 3, and the sequence always obeys its own counts.

What recurrence defines it?

a(n + 1) = 1 + a(n + 1 - a(a(n))), starting from a(1) = 1. The calculator generates terms by exactly this recurrence.

Is the Golomb sequence increasing?

It never decreases. It is non-decreasing - flat runs separated by single steps up - which is what makes the self-describing property possible.

Sources

Related calculators

Aliquot Sequence Calculator
Trace an aliquot sequence to its fate: termination at 0, a perfect fixed point, or an amicable or sociable cycle.
Arithmetic Sequence Calculator
The nth term and the sum of the first n terms of an arithmetic sequence from the first term and common difference.
Euclid-Mullin Sequence Calculator
Euclid-Mullin sequence terms: each is the smallest prime factor of one plus the product of all previous terms.