cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

This page as a plain text file.
%I A338789 #33 Dec 23 2020 17:23:52
%S A338789 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,
%T A338789 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,
%U A338789 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
%N 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.
%H A338789 S. Brunner, <a href="/A338789/b338789.txt">Table of n, a(n) for n = 1..10000</a>
%e A338789 The solution for a(5):
%e A338789 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:
%e A338789    1,2,4,[1],[1?] - not possible
%e A338789    [1,2],4,[1,2?] - not possible
%e A338789    1,2,[4],[1,3?] - not possible
%e A338789    1,2,[4],1,[4?] - not possible
%e A338789    1,2,[4,1],[5?] - not possible
%e A338789    1,[2,4],1,[6?] - not possible
%e A338789    1,[2,4,1],[7?] - not possible
%e A338789    [1,2,4,1],[8?] - not possible
%e A338789    1,2,4,1,9?
%e A338789 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.
%e A338789 Another example for a(8) = 21:
%e A338789   1,2,4,1,9,2,[1],[1?]   ;  1,2,4,1,9,[2],1,[2?]   ;  1,2,4,1,9,[2,1],[3?]
%e A338789   1,[2,4,1],9,[2,1,4?]   ;  [1,2,4,1],9,[2,1,5?]   ;  1,2,4,1,[9],[2,1,6?]
%e A338789   1,2,4,[1,9],[2,1,7?]   ;  1,2,4,1,[9],2,[1,8?]   ;  1,2,4,[1,9],2,[1,9?]
%e A338789   1,2,4,1,[9,2],[1,10?]  ;  1,2,4,1,[9,2],1,[11?]  ;  1,2,4,1,[9,2,1],[12?]
%e A338789   1,2,4,[1,9,2,1],[13?]  ;  [1,2,4,1,9],[2,1,14?]  ;  1,2,[4,1,9,2],[1,15?]
%e A338789   1,2,[4,1,9,2],1,[16?]  ;  1,2,[4,1,9,2,1],[17?]  ;  1,[2,4,1,9,2],1,[18?]
%e A338789   1,[2,4,1,9,2,1],[19?]  ;  [1,2,4,1,9,2,1],[20?]  ;  1,2,4,1,9,2,1,21?
%e A338789   -> a(8) = 21.
%o A338789 (Python)
%o A338789 def A(lastn):
%o A338789     n,a,chk,nchk=1,[],[],[]
%o A338789     while n<=lastn:
%o A338789         i=1
%o A338789         while i in chk: i+=1
%o A338789         for x, v in enumerate(chk): chk[x]=v-i
%o A338789         chk.extend(nchk)
%o A338789         for x, v in enumerate(nchk): nchk[x]=v+i
%o A338789         nchk.append(i)
%o A338789         chk.extend(nchk)
%o A338789         chk=[x for x in chk if x>0]
%o A338789         chk=list(set(chk))
%o A338789         a.append(i)
%o A338789         print(i)
%o A338789         n += 1
%o A338789     return a
%Y A338789 Cf. A002048.
%K A338789 nonn,look
%O A338789 1,2
%A A338789 _S. Brunner_, Nov 09 2020