A193840 Erroneous version of A227590.
2, 4, 7, 12, 20, 30, 46
Offset: 2
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.
The second term is 2 because the 3 pairwise sums 1+1=2, 1+2=3, 2+2=4 are all distinct. The third term cannot be 3 because 1+3 = 2+2. But it can be 4, since 1+4=5, 2+4=6, 4+4=8 are distinct and distinct from the earlier sums 1+1=2, 1+2=3, 2+2=4.
import Data.Set (Set, empty, insert, member) a005282 n = a005282_list !! (n-1) a005282_list = sMianChowla [] 1 empty where sMianChowla :: [Integer] -> Integer -> Set Integer -> [Integer] sMianChowla sums z s | s' == empty = sMianChowla sums (z+1) s | otherwise = z : sMianChowla (z:sums) (z+1) s where s' = try (z:sums) s try :: [Integer] -> Set Integer -> Set Integer try [] s = s try (x:sums) s | (z+x) `member` s = empty | otherwise = try sums $ insert (z+x) s -- Reinhard Zumkeller, Mar 02 2011
a[1]:= 1: P:= {2}: A:= {1}: for n from 2 to 100 do for t from a[n-1]+1 do Pt:= map(`+`,A union {t},t); if Pt intersect P = {} then break fi od: a[n]:= t; A:= A union {t}; P:= P union Pt; od: seq(a[n],n=1..100); # Robert Israel, Sep 21 2014
t = {1}; sms = {2}; k = 1; Do[k++; While[Intersection[sms, k + t] != {}, k++]; sms = Join[sms, t + k, {2 k}]; AppendTo[t, k], {49}]; t (* T. D. Noe, Mar 02 2011 *)
A005282_vec(N, A=[1], U=[0], D(A, n=#A)=vector(n-1, k, A[n]-A[n-k]))={ while(#A2 && U=U[k-1..-1]);A} \\ M. F. Hasler, Oct 09 2019
aupto(L)= my(S=vector(L), A=[1]); for(i=2, L, for(j=1, #A, if(S[i-A[j]], next(2))); for(j=1, #A, S[i-A[j]]=1); A=concat(A, i)); A \\ Ruud H.G. van Tol, Jun 30 2025
from itertools import count, islice def A005282_gen(): # generator of terms aset1, aset2, alist = set(), set(), [] for k in count(1): bset2 = {k<<1} if (k<<1) not in aset2: for d in aset1: if (m:=d+k) in aset2: break bset2.add(m) else: yield k alist.append(k) aset1.add(k) aset2 |= bset2 A005282_list = list(islice(A005282_gen(),30)) # Chai Wah Wu, Sep 05 2023
a(5)=11 because 0-1-4-9-11 (0-2-7-10-11) resp. 0-3-4-9-11 (0-2-7-8-11) are shortest: there is no b0-b1-b2-b3-b4 with different distances |bi-bj| and max. |bi-bj| < 11.
Min@@Total/@#&/@GatherBy[Select[Join@@Permutations/@Join@@Table[IntegerPartitions[i],{i,0,15}],UnsameQ@@ReplaceList[#,{_,s__,_}:>Plus[s]]&],Length] (* Gus Wiseman, May 17 2019 *)
from itertools import combinations, combinations_with_replacement, count def a(n): for k in count(n-1): for c in combinations(range(k), n-1): c = c + (k, ) ss = set() for s in combinations_with_replacement(c, 2): if sum(s) in ss: break else: ss.add(sum(s)) if len(ss) == n*(n+1)//2: return k # Jianing Song, Feb 14 2025, adapted from the python program of A345731
For n = 4, {1, 2, 4} is a subset of {1, 2, 3, 4} with distinct differences 2 - 1 = 1, 4 - 1 = 3, 4 - 2 = 2 between pairs of elements and no larger set has the required property; so a(4) = 3. From _Gus Wiseman_, Jun 07 2019: (Start) Examples of subsets realizing each largest size are: 0: {} 1: {1} 2: {1,2} 3: {2,3} 4: {1,3,4} 5: {2,4,5} 6: {3,5,6} 7: {1,3,6,7} 8: {2,4,7,8} 9: {3,5,8,9} 10: {4,6,9,10} 11: {5,7,10,11} 12: {1,4,5,10,12} 13: {2,5,6,11,13} 14: {3,6,7,12,14} 15: {4,7,8,13,15} (End)
Table[Length[Last[Select[Subsets[Range[n]],UnsameQ@@Subtract@@@Subsets[#,{2}]&]]],{n,0,15}] (* Gus Wiseman, Jun 07 2019 *)
Three tetrahedra labeled (1, 2, 8, 12) yield the 20 possible sums 3, 4, 5, 6, 10, 11, 12, 14, 15, 16, 17, 18, 21, 22, 24, 25, 26, 28, 32, 36. No more sums can be obtained by different labelings, and no labeling with labels < 12 yields 20 possible sums. Therefore A(4,3) = 12. Square array A(n,k) begins: 1, 1, 1, 1, 1, 1, 1, 1, ... 1, 2, 2, 2, 2, 2, 2, ... 1, 3, 4, 5, 6, 7, ... 1, 4, 7, 12, 16, ... 1, 5, 12, 24, ... 1, 6, 18, ... 1, 7, ... 1, ...
The triangle begins: 1 2 2 2 3 3 3 4 4 4 3 4 4 5 5 3 4 5 5 5 6 4 5 5 6 6 6 7 4 5 5 6 7 7 7 7 4 5 6 6 7 7 8 8 8 4 6 6 7 7 8 8 8 9 9 4 6 6 7 8 8 8 9 9 9 10 5 6 7 7 8 9 9 9 9 10 10 10 5 6 7 8 8 9 9 10 10 10 10 11 11
The 15 averages of 1 to 4 elements in the set {1, 2, 5, 7} (or alternately {1, 3, 6, 7}) are all different, so a(4) <= 7. There are no such sets of 4 positive integers with all members less than 7, so in fact a(4) = 7. The set providing the last term at present in the sequence, viz. 396 = a(9), is {1, 13, 21, 51, 151, 327, 336, 342, 396} (or, by symmetry, {1, 55, 61, 70, 246, 346, 376, 384, 396}).
n | example set -----+------------------------------------------------------- 1 | {1} 2 | {1, 2} 3 | {1, 2, 3} 4 | {1, 2, 3, 5} 5 | {1, 3, 4, 5, 6} 6 | {1, 3, 4, 5, 6, 7} 7 | {1, 2, 5, 6, 7, 8, 9} 8 | {1, 2, 5, 6, 7, 8, 9, 11} 9 | {1, 2, 5, 6, 7, 8, 9, 11, 13} 10 | {1, 2, 5, 7, 8, 9, 11, 12, 13, 15} 11 | {1, 2, 5, 7, 8, 9, 11, 12, 13, 15, 17} 12 | {1, 2, 5, 7, 8, 9, 11, 12, 13, 15, 17, 19} 13 | {1, 5, 6, 7, 9, 11, 13, 14, 15, 16, 17, 19, 20} 14 | {1, 2, 5, 7, 11, 12, 13, 16, 17, 18, 19, 20, 21, 23} For n = 4, the set {1,2,3,4} does not have distinct products because 2*2 = 1*4. However, the set {1,2,3,5} does have distinct products because 1*1, 1*2, 1*3, 1*5, 2*2, 2*3, 2*5, 3*3, 3*5, and 5*5 are all distinct.
Table[k=1;While[!Or@@(Length[s=Union[Sort/@Tuples[#,{2}]]]==Length@Union[Times@@@s]&/@Subsets[Range@k,{n}]),k++];k,{n,12}] (* Giorgos Kalogeropoulos, Sep 08 2021 *)
from itertools import combinations, combinations_with_replacement def a(n): k = n while True: for Srest in combinations(range(1, k), n-1): S = Srest + (k, ) allprods = set() for i, j in combinations_with_replacement(S, 2): if i*j in allprods: break else: allprods.add(i*j) else: return k k += 1 print([a(n) for n in range(1, 15)]) # Michael S. Branicky, Sep 08 2021
Triangle begins: 4; 7, 5; 12, 7, 6; 18, 10, 8, 7; 26, 14, 11, 9, 8; 35, 19, 14, 11, 10, 9; 45, ... ...
Comments