A380037 For n >= 1, if there exists an m < n such that a(m) = a(n), take the largest such m and set a(n+1) as 1 more than the number of positive terms between a(m+1) and a(n-1). Otherwise, a(n+1) = -1. Start with a(1) = 0.
0, -1, -1, 1, -1, 2, -1, 2, 1, 3, -1, 4, -1, 2, 4, 2, 2, 1, 7, -1, 7, 1, 3, 10, -1, 5, -1, 2, 8, -1, 3, 5, 4, 14, -1, 5, 3, 5, 2, 9, -1, 6, -1, 2, 3, 6, 3, 2, 4, 13, -1, 8, 18, -1, 3, 6, 8, 4, 7, 30, -1, 7, 2, 12, -1, 4, 6, 9, 22, -1, 5, 26
Offset: 1
Keywords
Links
- Connor Criss, Table of n, a(n) for n = 1..10000
Crossrefs
Similar to the Van Eck sequence A181391.
Programs
-
PARI
a(max_n) = {my(v = [0], r = [], n = 1); while(#v < max_n, r = select(x->x==v[n], v, 1); if(#r>1, v=concat(v, [1+sum(m=r[#r-1]+1, r[#r]-1, v[m]>0)]), v=concat(v,[-1])); n++); v} \\ Thomas Scheuerle, Jan 11 2025
-
Python
k = [0] i = 0 j = 0 n = 0 negatives = 0 total_vals = 0 MAX = 10000 #change value of MAX to modify number of terms generated index = 0 while(index < MAX): n = k[-1] i = len(k) - 2 j = 1 m = 0 while(i > -1): if(k[i] == k[-1]): k.append(j) m = 1 break if(k[i] != -1 or k[-1] == -1): j = j + 1 i = i - 1 if m == 0: k.append(-1) negatives = negatives + 1 index = index + 1 for x in range(MAX): print(str(k[x]))
Comments