OFFSET
1,5
COMMENTS
It appears that if you choose "otherwise a(n+1) = x" to be a different integer, that the sequence starts to look the same, but offset in position and value. For example, if you compare the case where "otherwise a1(n+1) = 1" and "otherwise a2(n+1) = 2" then a1(n) = a2(n+3)-2.
MATHEMATICA
a[1] = a[2] = 0; a[n_] := a[n] = Module[{k = n-2}, While[k > 0 && a[k] != a[n-1], k--]; If[k==0, 1, a[n-1] + n - k - 1]]; Array[a, 100] (* Amiram Eldar, Jul 12 2019 *)
PROG
(Python)
def Prog(length):
L = 2
seq = [0, 0]
while L < length:
x = len(seq)-1
while x > 0:
if seq[-1] == seq[x-1]:
m = len(seq)-x
a_n = seq[L-1]
seq.append(a_n+m)
x = -1
else:
x -= 1
if x == 0:
seq.append(1)
L += 1
return seq
CROSSREFS
KEYWORD
nonn
AUTHOR
Philip Kalisman, Jul 07 2019
STATUS
approved