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.

A345731 Additive bases: a(n) is the least integer such that there is an n-element set of integers between 0 and a(n), the sums of pairs (of distinct elements) of which are distinct.

This page as a plain text file.
%I A345731 #45 Aug 04 2025 17:19:45
%S A345731 1,2,4,7,12,18,24,34,45,57,71,86,105,126,148
%N A345731 Additive bases: a(n) is the least integer such that there is an n-element set of integers between 0 and a(n), the sums of pairs (of distinct elements) of which are distinct.
%C A345731 Such sets are known as weak Sidon sets, weak B_2 sets, or well-spread sequences.
%C A345731 n - 1 <= a(n) <= A003022(n). - _Michael S. Branicky_, Jun 25 2021
%D A345731 Alison M. Marr and W. D. Wallis, Magic Graphs, Birkhäuser, 2nd ed., 2013. See Section 2.3.
%D A345731 Xiaodong Xu, Meilian Liang, and Zehui Shao, On weak Sidon sequences, The Journal of Combinatorial Mathematics and Combinatorial Computing (2014), 107--113
%H A345731 A. Lladó, <a href="https://doi.org/10.1016/j.ejc.2007.04.006">Largest cliques in connected supermagic graphs</a>, European Journal of Combinatorics, Vol. 28, No. 8 (2007), 2240-2247.
%e A345731 a(6)=12 because 0-1-2-4-7-12 (0-5-8-10-11-12) resp. 0-1-2-6-9-12 (0-3-6-10-11-12) are shortest weak Sidon sets of size 6.
%e A345731 a(16)=148: [0, 3, 5, 6, 32, 49, 59, 68, 93, 106, 118, 126, 130, 134, 141, 148]. - _Zhao Hui Du_, Jul 27 2025
%t A345731 a[n_Integer?NonNegative] := Module[{k = n - 1}, While[SelectFirst[Subsets[Range[0, k - 1], {n - 1}], Length@Union[Plus @@@ Subsets[#~Join~{k}, {2}]] >= (n*(n - 1))/2 &] === Missing["NotFound"], k++]; k];
%t A345731 Table[a[n], {n, 2, 8}] (* _Robert P. P. McKone_, Nov 05 2023 *)
%o A345731 (Python)
%o A345731 from itertools import combinations, count
%o A345731 def a(n):
%o A345731     for k in count(n-1):
%o A345731         for c in combinations(range(k), n-1):
%o A345731             c = c + (k,)
%o A345731             ss = set()
%o A345731             for s in combinations(c, 2):
%o A345731                 if sum(s) in ss: break
%o A345731                 else: ss.add(sum(s))
%o A345731             if len(ss) == n*(n-1)//2: return k # use (k, c) for sets
%o A345731 print([a(n) for n in range(2, 9)]) # _Michael S. Branicky_, Jun 25 2021
%Y A345731 See A003022, A004133, and A004135 for other versions.
%K A345731 nonn,hard,more,nice
%O A345731 2,2
%A A345731 _Bernd Mulansky_, Jun 25 2021
%E A345731 a(16) corrected and a(17) deleted by _Zhao Hui Du_, Jul 27 2025