OFFSET
0,3
LINKS
Giovanni Resta, Table of n, a(n) for n = 0..10000 (first 7611 terms from D. Mondot)
FORMULA
a(n) = A011185(n+1) - 1. - Robert Israel, May 02 2016
MAPLE
N:= 10^6: # to get all terms <= N
A[0]:= 0: Delta:= {}: As:= {A[0]}:
Cands:= {$1..N}:
for n from 1 while Cands <> {} do
A[n]:= min(Cands);
Cands:= Cands minus ({A[n]} union map(`+`, Delta, A[n]));
Delta:= Delta union map(t ->A[n] - t, As);
As:= As union {A[n]};
od:
seq(A[i], i=0..n-1); # Robert Israel, May 02 2016
PROG
(MATLAB)
N = 3*10^8; % to get all terms < N
Cands = ones(N, 1);
Delta = [];
A = [];
n = 1;
while nnz(Cands) > 0
A(n) = find(Cands, 1, 'first');
Cands(A(n)) = 0;
Rem = Delta(Delta <= N - A(n)) + A(n);
Cands(Rem) = 0;
Delta = union(Delta, -A(1:n-1)+A(n));
if mod(n, 10)==0
fprintf('a(%d)=%d\n', n, A(n));
toc;
end
n = n + 1;
end
A - 1 % Robert Israel, May 02 2016
(Python)
from itertools import count, islice
def A010672_gen(): # generator of terms
aset2, alist = set(), []
for k in count(0):
bset2 = set()
for a in alist:
if (b:=a+k) in aset2:
break
bset2.add(b)
else:
yield k
alist.append(k)
aset2.update(bset2)
CROSSREFS
KEYWORD
nonn
AUTHOR
STATUS
approved