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> |
||
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: |
||
B: The next term is zero. |
|||
Otherwise: |
Otherwise: |
||
C: The next term is how far back this last term occured previousely. |
|||
</pre> |
</pre> |
||
;Example: |
;Example: |
||
Using |
Using A: |
||
:<code>0</code> |
:<code>0</code> |
||
Using |
Using B: |
||
:<code>0 0</code> |
:<code>0 0</code> |
||
Using |
Using C: |
||
:<code>0 0 1</code> |
:<code>0 0 1</code> |
||
Using |
Using B: |
||
:<code>0 0 1 0</code> |
:<code>0 0 1 0</code> |
||
Using |
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 |
Using B: |
||
:<code>0 0 1 0 2 0</code> |
:<code>0 0 1 0 2 0</code> |
||
Using |
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 |
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 |
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> |
||
... |
... |