Van Eck sequence: Difference between revisions

Content added Content deleted
(New draft task with python examples.)
 
(Fix, and change to less ambiguous letters.)
Line 2: Line 2:
The sequence is generated by following this pseudo-code:
The sequence is generated by following this pseudo-code:
<pre>
<pre>
1: The first term is zero.
A: The first term is zero.
Repeatedly apply:
Repeatedly apply:
If the last term is *new* to the sequence so far then:
If the last term is *new* to the sequence so far then:
2: The next term is zero.
B: The next term is zero.
Otherwise:
Otherwise:
3: The next term is how far back this last term occured previousely.
C: The next term is how far back this last term occured previousely.
</pre>
</pre>




;Example:
;Example:
Using 1:
Using A:
:<code>0</code>
:<code>0</code>
Using 2:
Using B:
:<code>0 0</code>
:<code>0 0</code>
Using 3:
Using C:
:<code>0 0 1</code>
:<code>0 0 1</code>
Using 2:
Using B:
:<code>0 0 1 0</code>
:<code>0 0 1 0</code>
Using 3: (zero last occured two steps back - before the one)
Using C: (zero last occured two steps back - before the one)
:<code>0 0 1 0 2</code>
:<code>0 0 1 0 2</code>
Using 1:
Using B:
:<code>0 0 1 0 2 0</code>
:<code>0 0 1 0 2 0</code>
Using 3: (two last occured two steps back - before the zero)
Using C: (two last occured two steps back - before the zero)
:<code>0 0 1 0 2 0 2 2</code>
:<code>0 0 1 0 2 0 2 2</code>
Using 3: (two last occured one step back)
Using C: (two last occured one step back)
:<code>0 0 1 0 2 0 2 2 1</code>
:<code>0 0 1 0 2 0 2 2 1</code>
Using 3: (one last appeared six steps back)
Using C: (one last appeared six steps back)
:<code>0 0 1 0 2 0 2 2 1 6</code>
:<code>0 0 1 0 2 0 2 2 1 6</code>
...
...