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.
%I A143823 #79 Sep 03 2025 15:42:10 %S A143823 1,2,4,7,13,22,36,57,91,140,216,317,463,668,962,1359,1919,2666,3694, %T A143823 5035,6845,9188,12366,16417,21787,28708,37722,49083,63921,82640, %U A143823 106722,136675,174895,222558,283108,357727,451575,567536,712856,890405,1112081,1382416,1717540 %N A143823 Number of subsets {x(1),x(2),...,x(k)} of {1,2,...,n} such that all differences |x(i)-x(j)| are distinct. %C A143823 When the set {x(1),x(2),...,x(k)} satisfies the property that all differences |x(i)-x(j)| are distinct (or alternately, all the sums are distinct), then it is called a Sidon set. So this sequence is basically the number of Sidon subsets of {1,2,...,n}. - _Sayan Dutta_, Feb 15 2024 %C A143823 See A143824 for sizes of the largest subsets of {1,2,...,n} with the desired property. %C A143823 Also the number of subsets of {1..n} such that every orderless pair of (not necessarily distinct) elements has a different sum. - _Gus Wiseman_, Jun 07 2019 %H A143823 Fausto A. C. Cariboni, <a href="/A143823/b143823.txt">Table of n, a(n) for n = 0..100</a> (terms 0..60 from Alois P. Heinz, 61..81 from Vaclav Kotesovec) %H A143823 Thomas Bloom, <a href="https://www.erdosproblems.com/861">Problem 861</a>, Erdős Problems. %H A143823 Terence Tao, <a href="https://github.com/teorth/erdosproblems/blob/main/README.md#table">Erdős problem database</a>, see no. 861. %H A143823 Wikipedia, <a href="https://en.wikipedia.org/wiki/Sidon_sequence">Sidon sequence</a>. %F A143823 a(n) = A169947(n-1) + n + 1 for n>=2. - _Nathaniel Johnston_, Nov 12 2010 %F A143823 a(n) = A054578(n) + 1 for n>0. - _Alois P. Heinz_, Jan 17 2013 %e A143823 {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, so {1,2,4} is counted as one of the 13 subsets of {1,2,3,4} with the desired property. Only 2^4-13=3 subsets of {1,2,3,4} do not have this property: {1,2,3}, {2,3,4}, {1,2,3,4}. %e A143823 From _Gus Wiseman_, May 17 2019: (Start) %e A143823 The a(0) = 1 through a(5) = 22 subsets: %e A143823 {} {} {} {} {} {} %e A143823 {1} {1} {1} {1} {1} %e A143823 {2} {2} {2} {2} %e A143823 {1,2} {3} {3} {3} %e A143823 {1,2} {4} {4} %e A143823 {1,3} {1,2} {5} %e A143823 {2,3} {1,3} {1,2} %e A143823 {1,4} {1,3} %e A143823 {2,3} {1,4} %e A143823 {2,4} {1,5} %e A143823 {3,4} {2,3} %e A143823 {1,2,4} {2,4} %e A143823 {1,3,4} {2,5} %e A143823 {3,4} %e A143823 {3,5} %e A143823 {4,5} %e A143823 {1,2,4} %e A143823 {1,2,5} %e A143823 {1,3,4} %e A143823 {1,4,5} %e A143823 {2,3,5} %e A143823 {2,4,5} %e A143823 (End) %p A143823 b:= proc(n, s) local sn, m; %p A143823 if n<1 then 1 %p A143823 else sn:= [s[], n]; %p A143823 m:= nops(sn); %p A143823 `if`(m*(m-1)/2 = nops(({seq(seq(sn[i]-sn[j], %p A143823 j=i+1..m), i=1..m-1)})), b(n-1, sn), 0) +b(n-1, s) %p A143823 fi %p A143823 end: %p A143823 a:= proc(n) option remember; %p A143823 b(n-1, [n]) +`if`(n=0, 0, a(n-1)) %p A143823 end: %p A143823 seq(a(n), n=0..30); # _Alois P. Heinz_, Sep 14 2011 %t A143823 b[n_, s_] := Module[{ sn, m}, If[n<1, 1, sn = Append[s, n]; m = Length[sn]; If[m*(m-1)/2 == Length[Table[sn[[i]] - sn[[j]], {i, 1, m-1}, {j, i+1, m}] // Flatten // Union], b[n-1, sn], 0] + b[n-1, s]]]; a[n_] := a[n] = b[n - 1, {n}] + If[n == 0, 0, a[n-1]]; Table [a[n], {n, 0, 30}] (* _Jean-François Alcover_, Nov 08 2015, after _Alois P. Heinz_ *) %t A143823 Table[Length[Select[Subsets[Range[n]],UnsameQ@@Abs[Subtract@@@Subsets[#,{2}]]&]],{n,0,15}] (* _Gus Wiseman_, May 17 2019 *) %o A143823 (Python) %o A143823 from itertools import combinations %o A143823 def is_sidon_set(s): %o A143823 allsums = [] %o A143823 for i in range(len(s)): %o A143823 for j in range(i, len(s)): %o A143823 allsums.append(s[i] + s[j]) %o A143823 if len(allsums)==len(set(allsums)): %o A143823 return True %o A143823 return False %o A143823 def a(n): %o A143823 sidon_count = 0 %o A143823 for r in range(n + 1): %o A143823 subsets = combinations(range(1, n + 1), r) %o A143823 for subset in subsets: %o A143823 if is_sidon_set(subset): %o A143823 sidon_count += 1 %o A143823 return sidon_count %o A143823 print([a(n) for n in range(20)]) # _Sayan Dutta_, Feb 15 2024 %o A143823 (Python) %o A143823 from functools import cache %o A143823 def b(n, s): %o A143823 if n < 1: return 1 %o A143823 sn = s + [n] %o A143823 m = len(sn) %o A143823 return (b(n-1, sn) if m*(m-1)//2 == len(set(sn[i]-sn[j] for i in range(m-1) for j in range(i+1, m))) else 0) + b(n-1, s) %o A143823 @cache %o A143823 def a(n): return b(n-1, [n]) + (0 if n==0 else a(n-1)) %o A143823 print([a(n) for n in range(31)]) # _Michael S. Branicky_, Feb 15 2024 after _Alois P. Heinz_ %Y A143823 First differences are A308251. %Y A143823 Second differences are A169942. %Y A143823 Row sums of A381476. %Y A143823 The maximal case is A325879. %Y A143823 The integer partition case is A325858. %Y A143823 The strict integer partition case is A325876. %Y A143823 Heinz numbers of the counterexamples are given by A325992. %Y A143823 Cf. A143824, A054578, A169947. %Y A143823 Cf. A000079, A108917, A143824, A169942, A308251, A325676, A325677, A325679, A325683, A325860, A325864, A241688, A241689, A241690. %K A143823 nonn,changed %O A143823 0,2 %A A143823 _John W. Layman_, Sep 02 2008 %E A143823 a(21)-a(29) from _Nathaniel Johnston_, Nov 12 2010 %E A143823 Corrected a(21)-a(29) and more terms from _Alois P. Heinz_, Sep 14 2011