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.

A010672 A B_2 sequence: a(n) = least value such that the sequence increases and pairwise sums of distinct terms are all distinct.

Original entry on oeis.org

0, 1, 2, 4, 7, 12, 20, 29, 38, 52, 73, 94, 127, 151, 181, 211, 257, 315, 373, 412, 475, 530, 545, 607, 716, 797, 861, 964, 1059, 1160, 1306, 1385, 1434, 1555, 1721, 1833, 1933, 2057, 2260, 2496, 2698, 2873, 3060, 3196, 3331, 3628, 3711, 3867, 4139, 4446, 4639
Offset: 0

Views

Author

Keywords

Crossrefs

A025582 is a similar sequence, but there the pairwise sums of (not necessarily distinct) elements are all distinct.
Cf. A011185.

Programs

  • 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
    
  • 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
  • Mathematica
    seq = {0};
    pairSums = {};
    nextTerm = 1;
    pairSumsUpdate := Join[pairSums, nextTerm + seq]
    hasDuplicates := ! DuplicateFreeQ[pairSumsUpdate]
    Do[
     While[hasDuplicates, nextTerm++];
     pairSums = pairSumsUpdate;
     AppendTo[seq, nextTerm];
     , 50]
    seq (* David Trimas, Dec 28 2024 *)
  • 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)
    A010672_list = list(islice(A010672_gen(),30)) # Chai Wah Wu, Sep 11 2023

Formula

a(n) = A011185(n+1) - 1. - Robert Israel, May 02 2016