Mathwords logoMathwords

Van Eck's Sequence — Definition, Formula & Example

Van Eck's sequence is a self-referential list of whole numbers that starts with 0. Each new term tells you how many steps back the previous term last appeared, or is 0 if the previous term has never appeared before.

Van Eck's sequence (an)n≥0(a_n)_{n \ge 0} (OEIS A181391) is defined by a0=0a_0 = 0 and, for n≥0n \ge 0: if there is an index m<nm < n with am=ana_m = a_n, then an+1=n−ma_{n+1} = n - m for the largest such mm; otherwise an+1=0a_{n+1} = 0. Its first terms are 0,0,1,0,2,0,2,2,1,6,0,5,0,2,6,5,4,0,…0, 0, 1, 0, 2, 0, 2, 2, 1, 6, 0, 5, 0, 2, 6, 5, 4, 0, \ldots

Key Formula

an+1={n−m,m=max⁡{k<n:ak=an} exists0,if an has not appeared beforea_{n+1} = \begin{cases} n - m, & m = \max\{k < n : a_k = a_n\} \text{ exists} \\ 0, & \text{if } a_n \text{ has not appeared before} \end{cases}
Where:
  • ana_n = The current term, at position n (positions start at 0)
  • mm = The most recent earlier position where the value ana_n appeared
  • n−mn - m = The gap between the current position and that earlier appearance

Worked Example

Problem: The first eight terms of Van Eck's sequence are a0a_0 through a7a_7: 0, 0, 1, 0, 2, 0, 2, 2. Find a8a_8, a9a_9, and a10a_{10}.
Step 1: Look at a7=2a_7 = 2. Before position 7, the value 2 last appeared at position 6. The gap is the difference of the positions.
a8=7−6=1a_8 = 7 - 6 = 1
Step 2: Now look at a8=1a_8 = 1. Before position 8, the value 1 last appeared at position 2.
a9=8−2=6a_9 = 8 - 2 = 6
Step 3: Now look at a9=6a_9 = 6. The value 6 has never appeared before, so the next term is 0.
a10=0a_{10} = 0
Answer: The next three terms are a8=1a_8 = 1, a9=6a_9 = 6, and a10=0a_{10} = 0, so the sequence continues 0, 0, 1, 0, 2, 0, 2, 2, 1, 6, 0.

Why It Matters

Van Eck's sequence shows how a one-line rule can produce behavior no one fully understands. It is proven that 0 appears infinitely often and that the sequence is unbounded, so it diverges. Whether every positive integer eventually appears is still an open question. It is also a standard programming exercise: storing the last position of each value in a dictionary lets you generate millions of terms quickly.

Common Mistakes

Mistake: Measuring the gap back to the first time a value appeared instead of the most recent time.
Correction: Always use the latest earlier position. At a7=2a_7 = 2, the value 2 appeared at positions 4 and 6. The correct gap is 7−6=17 - 6 = 1, not 7−4=37 - 4 = 3. Also count positions from 0, not 1.

Related Terms