login
A338789
Lexicographically earliest sequence of positive integers such that the sum of any number of consecutive terms can only repeat as sum of other consecutive terms after two or more terms between them.
1
1, 2, 4, 1, 9, 2, 1, 21, 2, 3, 1, 8, 2, 23, 18, 2, 8, 7, 9, 2, 1, 20, 16, 1, 21, 36, 3, 32, 2, 3, 4, 11, 13, 8, 2, 13, 27, 4, 18, 3, 7, 5, 8, 133, 3, 22, 31, 46, 19, 8, 47, 14, 3, 2, 14, 10, 44, 3, 5, 1, 10, 3, 9, 6, 19, 73, 39, 22, 36, 6, 1, 60, 17, 32, 227, 2, 134, 9, 45, 11, 33, 3, 37, 1, 8, 12, 14, 8, 1, 67
OFFSET
1,2
EXAMPLE
The solution for a(5):
We look through the numbers step by step and if groups with the same sum are less than 2 terms apart they are put in brackets:
1,2,4,[1],[1?] - not possible
[1,2],4,[1,2?] - not possible
1,2,[4],[1,3?] - not possible
1,2,[4],1,[4?] - not possible
1,2,[4,1],[5?] - not possible
1,[2,4],1,[6?] - not possible
1,[2,4,1],[7?] - not possible
[1,2,4,1],[8?] - not possible
1,2,4,1,9?
There are no 2 sums which contradict the definition of this sequence with a(5) = 9, so this is the next term. In this case we knew it must be the solution because the upper bound of a(n) is always the sum of all previous terms + 1.
Another example for a(8) = 21:
1,2,4,1,9,2,[1],[1?] ; 1,2,4,1,9,[2],1,[2?] ; 1,2,4,1,9,[2,1],[3?]
1,[2,4,1],9,[2,1,4?] ; [1,2,4,1],9,[2,1,5?] ; 1,2,4,1,[9],[2,1,6?]
1,2,4,[1,9],[2,1,7?] ; 1,2,4,1,[9],2,[1,8?] ; 1,2,4,[1,9],2,[1,9?]
1,2,4,1,[9,2],[1,10?] ; 1,2,4,1,[9,2],1,[11?] ; 1,2,4,1,[9,2,1],[12?]
1,2,4,[1,9,2,1],[13?] ; [1,2,4,1,9],[2,1,14?] ; 1,2,[4,1,9,2],[1,15?]
1,2,[4,1,9,2],1,[16?] ; 1,2,[4,1,9,2,1],[17?] ; 1,[2,4,1,9,2],1,[18?]
1,[2,4,1,9,2,1],[19?] ; [1,2,4,1,9,2,1],[20?] ; 1,2,4,1,9,2,1,21?
-> a(8) = 21.
PROG
(Python)
def A(lastn):
n, a, chk, nchk=1, [], [], []
while n<=lastn:
i=1
while i in chk: i+=1
for x, v in enumerate(chk): chk[x]=v-i
chk.extend(nchk)
for x, v in enumerate(nchk): nchk[x]=v+i
nchk.append(i)
chk.extend(nchk)
chk=[x for x in chk if x>0]
chk=list(set(chk))
a.append(i)
print(i)
n += 1
return a
CROSSREFS
Cf. A002048.
Sequence in context: A077387 A057551 A019823 * A174135 A182903 A169840
KEYWORD
nonn,look
AUTHOR
S. Brunner, Nov 09 2020
STATUS
approved