Computation Workshop Solution Checker

Van Erk's Sequence

Van Erk's Sequence begins in the following manner, with \(V(0)=V(1)=0\) and \(V(2)=1\).

\(V(0),V(1),V(2),V(3), \ldots = 0, 0, 1, 0, 2, 0, 2, 2, 1, 6, 0, 5, 0, 2, \ldots\)

Suppose the \(n^{th}\) term is \(V(n) = x\). Then the \((n+1)^{th}\) term is determined by:

  • If \(x\) has not appeared in the sequence before \(V(n)\), then \(V(n+1) = 0\).
  • Otherwise, if the \(k^{th}\) term is \(V(k) = x\) and this is the last appearance of \(x\) in the sequence before \(V(n)\), then \(V(n+1) = n-k\).
So for example \(V(9) = 6\) because the previous term is \(V(8) = 1\) and the last appearance of \(1\) in the sequence is \(V(2) = 1\). Whilst \(V(10) = 0\) because the previous term is \(V(9) = 6\) and the number \(6\) has not appeared in the sequence before \(V(9)\).

Part A Determine \(V(123)\)
Part B Determine \(V(1234567)\)