OFFSET
1,2
LINKS
S. Brunner, Table of n, a(n) for n = 1..10000
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
KEYWORD
nonn,look
AUTHOR
S. Brunner, Nov 09 2020
STATUS
approved