login
A308673
For n > 2, if there exists an m < n such that a(m) = a(n), take the largest such m and set a(n+1) = a(n)+(n-m); otherwise a(n+1) = 1. Start with a(1)=0, a(2)=0.
0
0, 0, 1, 1, 2, 1, 3, 1, 3, 5, 1, 4, 1, 3, 8, 1, 4, 9, 1, 4, 7, 1, 4, 7, 10, 1, 5, 22, 1, 4, 11, 1, 4, 7, 17, 1, 5, 15, 1, 4, 11, 21, 1, 5, 12, 1, 4, 11, 18, 1, 5, 12, 19, 1, 5, 9, 47, 1, 5, 9, 13, 1, 5, 9, 13, 17, 48, 1, 7, 42
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
Cf. A181391.
Sequence in context: A163313 A337178 A321893 * A324287 A213594 A335105
KEYWORD
nonn
AUTHOR
Philip Kalisman, Jul 07 2019
STATUS
approved