# Van Eck's sequence

In recreational mathematics van Eck's sequence is an integer sequence defined recursively as follows. Let a0 = 0. Then, for n ≥ 0, if there exists an m < n such that am = an, take the largest such m and set an+1 = n − m; otherwise an+1 = 0. Thus the first occurrence of an integer in the sequence is followed by a 0, and the second and subsequent occurrences are followed by the size of the gap between the two most recent occurrences.

The sequence is named after Jan Ritsema van Eck, who submitted it to the On-Line Encyclopedia of Integer Sequences.

The first few terms of the sequence are(OEIS: A181391):

0, 0, 1, 0, 2, 0, 2, 2, 1, 6, 0, 5, 0, 2, 6, 5, 4, 0, 5 ... 

The sequence was named by Neil Sloane after Jan Ritsema van Eck, who contributed it to the On-Line Encyclopedia of Integer Sequences in 2010.

## Properties

It is known that the sequence contains infinitely many zeros and that it is unbounded.

It is conjectured, but not proved, that the sequence contains every positive integer, and that every pair of non-negative integers apart from (1,1) appears as consecutive terms in the sequence.

## Variations

The sequence OEIS: A181391 is defined with a0 = 0. This can be changed such that the sequence starts with any integer.

For Example:

With a0 = 1, OEIS: A171911:

1, 0, 0, 1, 3, 0, 3, 2, 0, 3, 3, 1, 8, 0, 5, 0, 2, 9, 0, 3 ...

With a0 = 2, OEIS: A171912:

2, 0, 0, 1, 0, 2, 5, 0, 3, 0, 2, 5, 5, 1, 10, 0, 6, 0, 2, 8 ...

In fact, OEIS has eight other entries, from A171911 to A171918, corresponding to the separate sequences generated with a0 = 1 to 8.