login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Smallest number such that the circular adjacent sum set has no multiple entries.
1

%I #21 Sep 05 2023 18:26:14

%S 1,2,4,8,10,16,20,28,42,30,32,52,50,68,44,96,76,142,80,148,180,56,138,

%T 226,94,188,108,92,286,306,166,256,98,498,150,266,450,250,262,540,290,

%U 460,398,474,412,402,598,272,692,144,544,240,110,906,494,752,854,248

%N Smallest number such that the circular adjacent sum set has no multiple entries.

%C Let a1, a2, ..., ak be the first k terms of a sequence. The term "circular adjacent sum set" is the set of sums of 1 to k adjacent terms, where a1 is taken to be adjacent to ak. For example if the first 3 terms of the sequence are 1, 2, and 4 then the circular adjacent sum set is {1,2,4,3,6,5,7}.

%C Another example. If the first three terms of the sequence are 1,2,3 then the circular adjacent sum set is {1,2,3,3,5,4,7}. One element is repeated because 3 is the sum of adjacent elements in 2 ways, as 3 and as 1+2.

%e For n=4, and a(1)=1, a(2)=2, and a(3)=4. a(4) cannot be 1, 2, or 3 because then there would be two different sums equal to 3. a(4) cannot be 5 because 5+1=2+4. It cannot be 6 because 6=2+4. It cannot be 7 because 7=4+2+1. For a(4)=8 the circular adjacent sum set is {1,2,4,8,3,6,12,9,7,14,13,11,15}. All 13 of these sums are different, so a(4) is 8.

%t ok[v_] := Block[{w = v, n = Length@v}, w=Reap[Do[w = RotateLeft[w]; Do[Sow[ Total@ Take[w, j]], {j, n - 1}], {n}]][[2, 1]]; Length[w] == Length@ Union@ w]; a = {1}; While[Length[a] < 30, AppendTo[a, 2]; While[! ok[a], a[[-1]]++]]; a (* _Giovanni Resta_, May 30 2017 *)

%o (Python)

%o a, isums, lsums, rsums, xsums = [], set(), set([0]), set([0]), set([0])

%o for i in range(100):

%o for new in range(1, sum(a)+2):

%o nrsums, nxsums = set([0]), set([0])

%o for x in rsums:

%o xn = x+new

%o if xn in isums or xn in lsums:

%o break

%o nrsums.add(xn)

%o else:

%o for x in xsums.union(lsums):

%o xn = x+new

%o if xn in isums or xn in rsums or xn in lsums:

%o break

%o nxsums.add(xn)

%o else:

%o a.append(new)

%o isums.update(rsums)

%o xsums, rsums = nxsums, nrsums

%o lsums.add(sum(a))

%o break

%o print(a)

%o # _Andrey Zabolotskiy_, May 30 2017

%o (Python)

%o from itertools import count, islice

%o def A287178_gen(): # generator of terms

%o aset1, aset2, alist, n = set(), set(), [], 0

%o for k in count(1,2):

%o bset2 = {k<<1}

%o if (k<<1) not in aset2:

%o for d in aset1:

%o if (m:=d+k) in aset2:

%o break

%o bset2.add(m)

%o else:

%o yield k-n

%o n = k

%o alist.append(k)

%o aset1.add(k)

%o aset2.update(bset2)

%o A287178_list = list(islice(A287178_gen(),41)) # _Chai Wah Wu_, Sep 05 2023

%K nonn

%O 1,2

%A _David S. Newman_, May 21 2017

%E More terms from _Andrey Zabolotskiy_, May 30 2017