Output the Nth term of the Van Eck Sequence.
Van Eck Sequence is defined as:
- Starts with 0.
- If the last term is the first occurrence of that term the next term is 0.
- If the last term has occurred previously the next term is how many steps back was the most recent occurrence.
Input | Output
- 1 | 0
- 8 | 2
- 19 | 5
- 27 | 9
- 52 | 42
- 64 | 0
1 indexed is preferred, 0 indexed is acceptable; that might change some of the already submitted solutions.
Just the Nth term please.
Same (except for the seeing it already posted part), it seems code golfers and numberphile watchers have a decent overlap.