OFFSET
0,3
COMMENTS
In other words, a(n) is the minimum sum of a maximal Sidon set of {1..n}.
a(n) is also the minimum sum of a maximal subset of {1..n} such that every pair of distinct elements has a distinct difference.
LINKS
EXAMPLE
a(0) = 0 = sum of {}.
a(1) = 1 = sum of {1}.
a(2) = 3 = sum of {1,2}.
a(3) = 3 = sum of {1,2}.
a(4) = 5 = sum of {2,3}.
a(5) = 7 = sum of {1,2,4}.
a(12) = 15 = sum of {1,2,5,7} or {1,2,4,8}.
a(20) = 28 = sum of {2,5,10,11} or {1,2,4,8,13}.
See also the examples in A325879.
PROG
(PARI)
a(n)={
my(ismaxl(b, w)=for(k=1, n, if(!bittest(b, k) && !bitand(w, bitor(b, 1<<k)<<k), return(0))); 1);
my(recurse(k, b, w)=
if(k > n, if(ismaxl(b, w), 0, n^2),
my(s=self()(k+1, b, w));
b+=1<<k; if(!bitand(w, b<<k), s=min(s, k+self()(k+1, b, w + (b<<k))));
s);
);
recurse(1, 0, 0);
}
CROSSREFS
KEYWORD
nonn,changed
AUTHOR
Andrew Howroyd, Oct 27 2024
STATUS
approved