OFFSET
0,4
COMMENTS
Inspired by A316774.
In this sequence, it is obvious that we have exactly three 1’s that are a(0) = a(1) = a(2) = 1. Can we determine the frequency characteristics of some other positive integers? For example, are there infinitely many 2's in this sequence?
LINKS
Antti Karttunen, Table of n, a(n) for n = 0..65537
Altug Alkan, A line graph of a(n) for n <= 500
MAPLE
b:= proc() 0 end:
a:= proc(n) option remember; local t;
t:= `if`(n<3, 1, b(a(n-1))+b(a(n-3)));
b(t):= b(t)+1; t
end:
seq(a(n), n=0..100); # after Alois P. Heinz at A316774
MATHEMATICA
c = <||>; f[n_] := If[KeyExistsQ[c, n], c[n], 0]; a[n_] := a[n] = Block[{v}, v = If[n<3, 1, f[a[n-1]] + f[a[n-3]]]; If[f[v]>0, c[v] = c[v]+1, c[v]=1]; v]; Array[a, 93, 0] (* Giovanni Resta, Jul 24 2018 *)
PROG
(PARI)
up_to = 5000;
listA317127off1(up_to) = { my(v = vector(up_to), c); v[1] = v[2] = v[3] = 1; for(n=4, up_to, c=0; for(k=1, (n-1), c += ((v[k]==v[n-1])+(v[k]==v[n-3]))); v[n] = c); (v); };
listA317127off1(up_to) = { my(v = vector(up_to), m = Map(), c); v[1] = v[2] = v[3] = 1; mapput(m, 1, 3); for(n=4, up_to, c = (mapget(m, v[n-1])+mapget(m, v[n-3])); v[n] = c; mapput(m, c, if(!mapisdefined(m, c), 1, 1+mapget(m, c)))); (v); }; \\ Faster!
v317127 = listA317127off1(1+up_to);
A317127(n) = v317127[1+n]; \\ Antti Karttunen, Jul 23 2018
CROSSREFS
KEYWORD
nonn,look
AUTHOR
Altug Alkan, Jul 21 2018
STATUS
approved