%I #34 Nov 03 2023 23:31:50
%S 0,1,2,4,7,12,20,29,38,52,73,94,127,151,181,211,257,315,373,412,475,
%T 530,545,607,716,797,861,964,1059,1160,1306,1385,1434,1555,1721,1833,
%U 1933,2057,2260,2496,2698,2873,3060,3196,3331,3628,3711,3867,4139,4446,4639
%N A B_2 sequence: a(n) = least value such that the sequence increases and pairwise sums of distinct terms are all distinct.
%H Giovanni Resta, <a href="/A010672/b010672.txt">Table of n, a(n) for n = 0..10000</a> (first 7611 terms from D. Mondot)
%H <a href="/index/Br#B_2">Index entries for B_2 sequences</a>.
%F a(n) = A011185(n+1) - 1. - _Robert Israel_, May 02 2016
%p N:= 10^6: # to get all terms <= N
%p A[0]:= 0: Delta:= {}: As:= {A[0]}:
%p Cands:= {$1..N}:
%p for n from 1 while Cands <> {} do
%p A[n]:= min(Cands);
%p Cands:= Cands minus ({A[n]} union map(`+`,Delta, A[n]));
%p Delta:= Delta union map(t ->A[n] - t, As);
%p As:= As union {A[n]};
%p od:
%p seq(A[i],i=0..n-1); # _Robert Israel_, May 02 2016
%o (MATLAB)
%o N = 3*10^8; % to get all terms < N
%o Cands = ones(N,1);
%o Delta = [];
%o A = [];
%o n = 1;
%o while nnz(Cands) > 0
%o A(n) = find(Cands,1,'first');
%o Cands(A(n)) = 0;
%o Rem = Delta(Delta <= N - A(n)) + A(n);
%o Cands(Rem) = 0;
%o Delta = union(Delta, -A(1:n-1)+A(n));
%o if mod(n,10)==0
%o fprintf('a(%d)=%d\n',n,A(n));
%o toc;
%o end
%o n = n + 1;
%o end
%o A - 1 % _Robert Israel_, May 02 2016
%o (Python)
%o from itertools import count, islice
%o def A010672_gen(): # generator of terms
%o aset2, alist = set(), []
%o for k in count(0):
%o bset2 = set()
%o for a in alist:
%o if (b:=a+k) in aset2:
%o break
%o bset2.add(b)
%o else:
%o yield k
%o alist.append(k)
%o aset2.update(bset2)
%o A010672_list = list(islice(A010672_gen(),30)) # _Chai Wah Wu_, Sep 11 2023
%Y A025582 is a similar sequence, but there the pairwise sums of (not necessarily distinct) elements are all distinct.
%Y Cf. A011185.
%K nonn
%O 0,3
%A _Dan Hoey_