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.

Showing 1-2 of 2 results.

A004978 a(n) = least integer m > a(n-1) such that m - a(n-1) != a(j) - a(k) for all j, k less than n; a(1) = 1, a(2) = 2.

Original entry on oeis.org

1, 2, 4, 8, 13, 21, 31, 45, 60, 76, 97, 119, 144, 170, 198, 231, 265, 300, 336, 374, 414, 456, 502, 550, 599, 649, 702, 759, 819, 881, 945, 1010, 1080, 1157, 1237, 1318, 1401, 1486, 1572, 1662, 1753, 1845, 1945, 2049, 2156, 2264, 2380, 2499, 2623, 2750, 2882
Offset: 1

Views

Author

N. J. A. Sloane. This was in the 1973 "Handbook", but was then dropped from the database. Resubmitted by Clark Kimberling. Entry revised by N. J. A. Sloane, Jun 10 2012

Keywords

Comments

Equivalently, if S(n) = { a(j) - a(k); n > j > k > 0 }, then a(n) = a(n-1) + M where M = min( {1, 2, 3, ...} \ S(n) ) is the smallest positive integer not in S(n). - M. F. Hasler, Jun 26 2019

Examples

			From _M. F. Hasler_, Jun 26 2019: (Start)
After a(1) = 1, a(2) = 2, we have a(3) = least m > a(2) such that m - a(2) = m - 2 is not in { a(j) - a(k); 1 <= k < j < 3 } = { a(2) - a(1) } = { 1 }. Thus we must have m - 2 = 2, whence m = 4.
The next term a(4) is the least m > a(3) such that m - a(3) = m - 4 is not in { a(j) - a(k); 1 <= k < j < 4 } = { 1, 4 - 2 = 2, 4 - 1 = 3 }, i.e., m = 4 + 4 = 8.
The next term a(5) is the least m > a(4) such that m - a(4) = m - 8 is not in { a(j) - a(k); 1 <= k < j < 5 } = { 1, 2, 3, 8 - 4 = 4, 8 - 2 = 6, 8 - 1 = 7 }, i.e., m = 5 + 8 = 13. (End)
		

References

  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).

Crossrefs

Differences give A002048, see also A048201.
See also A001856.
For n>2, a(n) equals A002049(n-1)+1 and A048204(n-2)+2.

Programs

  • MATLAB
    s=1:2000^2;d(1)=1;A004978(1)=1;A004978(2)=2;
    for n=3:2000
      A004978(n)=A004978(n-1)+find([d,0]~=s(1:max(size(d))+1),1);
      d(end+1:end+n-1)=A004978(n)-A004978(1:n-1);
      d=sort(unique(d));
    end
    % Nathaniel Johnston, Feb 09 2011
    
  • PARI
    A004978_vec(N,a=[1..N],S=[1])={for(n=3,N,a[n]=a[n-1]+S[1]+1;S=setunion(S,select(t->t>S[1],vector(n-1,k,a[n]-a[n-k])));for(k=1,#S-1, if(S[k+1]-S[k]>1, S=S[k..-1];next(2)));S[#S]==#S&&S=[#S]);a} \\ M. F. Hasler, Jun 26 2019
    
  • Python
    from itertools import count, accumulate, islice
    from collections import deque
    def A004978_gen(): # generator of terms
        aset, alist, c = set(), deque(), 1
        for k in count(1):
            if k in aset:
                aset.remove(k)
            else:
                yield c
                aset |= set(k+d for d in accumulate(alist))
                alist.appendleft(k)
                c += k
    A004978_list = list(islice(A004978_gen(),20)) # Chai Wah Wu, Sep 01 2025

Extensions

Definition corrected by Bryan S. Robinson, Mar 16 2006
Name edited by M. F. Hasler, Jun 26 2019

A002049 Prime numbers of measurement.

Original entry on oeis.org

1, 3, 7, 12, 20, 30, 44, 59, 75, 96, 118, 143, 169, 197, 230, 264, 299, 335, 373, 413, 455, 501, 549, 598, 648, 701, 758, 818, 880, 944, 1009, 1079, 1156, 1236, 1317, 1400, 1485, 1571, 1661, 1752, 1844, 1944, 2048, 2155, 2263, 2379, 2498, 2622, 2749, 2881
Offset: 1

Views

Author

Keywords

Comments

Partial sums of A002048. - Reinhard Zumkeller, May 23 2013

References

  • R. K. Guy, Unsolved Problems in Number Theory, E30.
  • Š. Porubský, On MacMahon's segmented numbers and related sequences. Nieuw Arch. Wisk. (3) 25 (1977), no. 3, 403--408. MR0485763 (58 #5575)
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Cf. A002048.
a(n) = A004978(n+1)-1 = A048204(n-1)+1.

Programs

  • Haskell
    import Data.List ((\\))
    a002049 n = a002049_list !! (n-1)
    a002049_list = g [1..] [] where
       g (x:xs) ys = (last zs) : g (xs \\ zs) (x : ys) where
         zs = scanl (+) x ys
    -- Reinhard Zumkeller, May 23 2013
    
  • Mathematica
    A002048[anmax_] := (a = {}; Do[AppendTo[a, i], {i, 1, anmax}]; asum = {a[[1]] + a[[2]], a[[2]]}; Do[AppendTo[asum, 0], {i, 3, anmax}]; piv = 3; While[piv <= Length[a], Do[a = DeleteCases[a, asum[[i]]], {i, 1, piv - 2}]; Do[asum[[i]] += a[[piv]], {i, 1, piv}]; piv = piv + 1;]; a); A002048[200] // Accumulate (* Jean-François Alcover, Oct 05 2016, adapted from R. J. Mathar's Maple code in A002048. *)
  • Python
    from itertools import count, accumulate, islice
    from collections import deque
    def A002049_gen(): # generator of terms
        aset, alist, c = set(), deque(), 0
        for k in count(1):
            if k in aset:
                aset.remove(k)
            else:
                yield (c:=c+k)
                aset |= set(k+d for d in accumulate(alist))
                alist.appendleft(k)
    A002049_list = list(islice(A002049_gen(),20)) # Chai Wah Wu, Sep 01 2025

Formula

Andrews conjectures that a(n) ~ (1/2) n^2 log n / loglog n. - N. J. A. Sloane, Dec 01 2013
Showing 1-2 of 2 results.