OFFSET
1,7
COMMENTS
In Van Eck's sequence, b(n) is the distance between b(n-1) and the previous occurrence of b(n-1) there. Taking a(n) = b(n-b(n)) is therefore the distance between the second and third last occurrence of b(n-1) there.
If b(n-1) has not yet occurred three times then the result is a(n) = 0 either by b(n)=0 when b(n-1) has only occurred once, or b(n-b(n)) = 0 when b(n-1) has only occurred twice.
EXAMPLE
b(14) is 2, so we count back two steps to b(12), which is 5. Therefore a(14) = 5. As b(14-1) = b(13) = 0, the three occurrences of 0's are separated by b(14) and b(12) = a(14), that is, 2 and 5 steps:
.
n: ... 5 6 7 8 9 10 11 12 13 14 15 16 ...
.
|<--------5-------->|<--2-->|
| | |
| | |
b(n): ... 2, 0, 2, 2, 1, 6, 0, 5, 0, 2, 6, 5, ...
| |
v |
a(14) = 5 <-----
two steps
back
PROG
(PARI) A181391_vec(N, a=0, i=Map())={vector(N, n, a=if(n>1, iferr(n-mapget(i, a), E, 0)+mapput(i, a, n)))};
lista(nn) = my(v = A181391_vec(nn)); vector(#v, k, v[k-v[k]]); \\ Michel Marcus, Dec 11 2022
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Tamas Sandor Nagy, Dec 10 2022
STATUS
approved