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-10 of 10 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

A048201 Triangular array T read by rows: T(i,j)=b(i+1)-b(i+1-j); j=1,2,...,i; i=1,2,3,...; b=A004978.

Original entry on oeis.org

1, 2, 3, 4, 6, 7, 5, 9, 11, 12, 8, 13, 17, 19, 20, 10, 18, 23, 27, 29, 30, 14, 24, 32, 37, 41, 43, 44, 15, 29, 39, 47, 52, 56, 58, 59, 16, 31, 45, 55, 63, 68, 72, 74, 75, 21, 37, 52, 66, 76, 84, 89, 93, 95, 96, 22, 43, 59, 74, 88, 98, 106, 111
Offset: 1

Views

Author

Keywords

Examples

			Rows: {1}, {2,3},{4,6,7}, ...
		

Crossrefs

T(n, 1)=c(n), where c=A002048.
T(n, n)=d(n), where d=A002049.

Formula

T(n, 1)=least number not in any preceding row and T(n, k)=T(n, 1)+T(n-1, 1)+...+T(n-k+1, 1) for k >= 2.

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

A005242 A self-generating sequence.

Original entry on oeis.org

1, 2, 4, 5, 8, 10, 12, 14, 15, 16, 19, 20, 21, 24, 25, 27, 28, 32, 33, 34, 37, 38, 40, 42, 43, 44, 46, 47, 48, 51, 53, 54, 56, 57, 58, 59, 61, 62, 63, 64, 66, 68, 69, 72, 73, 74, 77, 79, 81, 83, 84, 86, 88, 89, 91, 92, 94, 96, 97, 98, 100
Offset: 1

Views

Author

Keywords

Comments

Presumably this is the lexicographically earliest sequence of distinct positive numbers with the property that sums of two or three consecutive earlier terms are excluded. - N. J. A. Sloane, Jan 07 2021

References

  • R. K. Guy, Unsolved Problems in Number Theory, E30.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Programs

  • Haskell
    import Data.List ((\\))
    a005242 n = a005242_list !! (n-1)
    a005242_list = f [1..] 0 0 where
       f (x:xs) y z = x : f (xs \\ [x + y, x + y + z]) x y
    -- Reinhard Zumkeller, May 23 2013

Extensions

More terms from Jud McCranie, Feb 15 1997

A145198 a(n) is the least number not already in the sequence and not the product of consecutive terms in the sequence.

Original entry on oeis.org

1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76, 77, 78, 79, 80
Offset: 1

Views

Author

Gerald Hillier, Oct 04 2008

Keywords

Crossrefs

Cf. A002048, A145278 (complement).

Programs

  • PARI
    {m=72; v=vector(m); z=2*m; u=vectorsmall(z); k=1; for(n=1, m, while(u[k], k++); v[n]=k; u[k]=1; j=n-1; p=k; while(j>0&&(p=p*v[j])<=z, u[p]=1; j--)); for(i=1, m, print1(v[i], ","))} \\ Klaus Brockhaus, Oct 06 2008
    (HP 49G)
    HP 49G calculator program from Gerald Hillier, Oct 24 2008
    << 0 OVER NDUPN
    ->LIST DUPDUP + 1 0
    0 -> M V U K J P
    << 1 M
    FOR N K
    WHILE U OVER
    GET
    REPEAT 1 +
    END 'K' STO V
    N K PUT 'V' STO U K
    1 PUT N 1 - 'J' STO
    K 'P' STO
    WHILE J 0 >
    IF
    THEN P V J
    GET * DUP 'P' STO M
    2 * <=
    ELSE 0
    END
    REPEAT P 1
    PUT J 1 - 'J' STO
    END 'U' STO
    NEXT V
    >>
    >>
    
  • Python
    from operator import mul
    from itertools import count, accumulate, islice
    from collections import deque
    def A145198_gen(): # generator of terms
        aset, alist = set(), deque()
        for k in count(1):
            if k in aset:
                aset.remove(k)
            else:
                yield k
                aset |= set(k*d for d in accumulate(alist,mul))
                alist.appendleft(k)
    A145198_list = list(islice(A145198_gen(),50)) # Chai Wah Wu, Sep 01 2025

Extensions

Extended by Klaus Brockhaus, Oct 06 2008

A362040 a(n) is the number of distinct sums of one or more contiguous terms in the sequence thus far.

Original entry on oeis.org

0, 1, 2, 4, 7, 10, 15, 21, 26, 34, 42, 52, 63, 75, 86, 96, 109, 125, 142, 160, 179, 197, 216, 238, 259, 281, 306, 332, 359, 387, 416, 442, 473, 505, 536, 567, 600, 636, 669, 707, 746, 784, 823, 865, 906, 948, 992, 1036, 1083, 1129, 1172, 1222, 1269, 1321, 1374, 1428
Offset: 1

Views

Author

Neal Gersh Tolunsky, Apr 15 2023

Keywords

Examples

			At n=1, there are no contiguous subsequences, so a(1)=0.
At n=2, there is one contiguous subsequence: [0], so a(2)=1.
At n=3, there are three contiguous subsequences: [0], [1] and [0, 1], but only two distinct sums (0 and 1), so a(3)=2.
		

Crossrefs

Cf. A361798 (number of sums).

Programs

  • Python
    from itertools import islice
    def gen_a():
        seen = set()
        sums = []
        new = 0
        while True:
            for v in sums: seen.add(v + new)
            sums = [v + new for v in sums]
            sums.append(0)
            new = len(seen)
            yield new
    print(list(islice(gen_a(), 60))) # Winston de Greef, Apr 15 2023

Formula

a(n) <= A000217(n).

Extensions

a(13)-a(15) corrected and more terms from Winston de Greef, Apr 15 2023

A048202 a(n)=T(n,2), array T given by A048201.

Original entry on oeis.org

3, 6, 9, 13, 18, 24, 29, 31, 37, 43, 47, 51, 54, 61, 67, 69, 71, 74, 78, 82, 88, 94, 97, 99, 103, 110, 117, 122, 126, 129, 135, 147, 157, 161, 164, 168, 171, 176, 181, 183, 192, 204, 211, 215, 224, 235, 243, 251, 259, 265, 270, 278
Offset: 2

Views

Author

Keywords

Crossrefs

Programs

  • Python
    from itertools import count, accumulate, islice
    from collections import deque
    def A048202_gen(): # generator of terms
        aset, alist = {1}, deque([1])
        for k in count(2):
            if k in aset:
                aset.remove(k)
            else:
                yield k+alist[0]
                aset |= set(k+d for d in accumulate(alist))
                alist.appendleft(k)
    A048202_list = (list(islice(A048202_gen(),52))) # Chai Wah Wu, Sep 02 2025

Formula

a(n) = A002048(n) + A002048(n+1). [Gerald Hillier, Oct 04 2008]

A048206 a(n)=least m such that row m of T contains n, array T given by A048201.

Original entry on oeis.org

1, 2, 2, 3, 4, 3, 3, 5, 4, 6, 4, 4, 5, 7, 8, 9, 5, 6, 5, 5, 10, 11, 6, 7, 12, 13, 6, 14, 6, 6, 9, 7, 15, 16, 17, 18, 7, 19, 8, 20, 7, 21, 7, 7, 9, 22, 8, 23, 24, 25, 13, 8, 26, 14, 9, 8, 27, 8, 8, 28, 15, 29, 9, 30, 31, 10, 16, 9, 17, 32, 18, 9, 13, 9, 9
Offset: 1

Views

Author

Keywords

Crossrefs

Programs

  • PARI
    See Links section.

A338789 Lexicographically earliest sequence of positive integers such that the sum of any number of consecutive terms can only repeat as sum of other consecutive terms after two or more terms between them.

Original entry on oeis.org

1, 2, 4, 1, 9, 2, 1, 21, 2, 3, 1, 8, 2, 23, 18, 2, 8, 7, 9, 2, 1, 20, 16, 1, 21, 36, 3, 32, 2, 3, 4, 11, 13, 8, 2, 13, 27, 4, 18, 3, 7, 5, 8, 133, 3, 22, 31, 46, 19, 8, 47, 14, 3, 2, 14, 10, 44, 3, 5, 1, 10, 3, 9, 6, 19, 73, 39, 22, 36, 6, 1, 60, 17, 32, 227, 2, 134, 9, 45, 11, 33, 3, 37, 1, 8, 12, 14, 8, 1, 67
Offset: 1

Views

Author

S. Brunner, Nov 09 2020

Keywords

Examples

			The solution for a(5):
We look through the numbers step by step and if groups with the same sum are less than 2 terms apart they are put in brackets:
   1,2,4,[1],[1?] - not possible
   [1,2],4,[1,2?] - not possible
   1,2,[4],[1,3?] - not possible
   1,2,[4],1,[4?] - not possible
   1,2,[4,1],[5?] - not possible
   1,[2,4],1,[6?] - not possible
   1,[2,4,1],[7?] - not possible
   [1,2,4,1],[8?] - not possible
   1,2,4,1,9?
There are no 2 sums which contradict the definition of this sequence with a(5) = 9, so this is the next term. In this case we knew it must be the solution because the upper bound of a(n) is always the sum of all previous terms + 1.
Another example for a(8) = 21:
  1,2,4,1,9,2,[1],[1?]   ;  1,2,4,1,9,[2],1,[2?]   ;  1,2,4,1,9,[2,1],[3?]
  1,[2,4,1],9,[2,1,4?]   ;  [1,2,4,1],9,[2,1,5?]   ;  1,2,4,1,[9],[2,1,6?]
  1,2,4,[1,9],[2,1,7?]   ;  1,2,4,1,[9],2,[1,8?]   ;  1,2,4,[1,9],2,[1,9?]
  1,2,4,1,[9,2],[1,10?]  ;  1,2,4,1,[9,2],1,[11?]  ;  1,2,4,1,[9,2,1],[12?]
  1,2,4,[1,9,2,1],[13?]  ;  [1,2,4,1,9],[2,1,14?]  ;  1,2,[4,1,9,2],[1,15?]
  1,2,[4,1,9,2],1,[16?]  ;  1,2,[4,1,9,2,1],[17?]  ;  1,[2,4,1,9,2],1,[18?]
  1,[2,4,1,9,2,1],[19?]  ;  [1,2,4,1,9,2,1],[20?]  ;  1,2,4,1,9,2,1,21?
  -> a(8) = 21.
		

Crossrefs

Cf. A002048.

Programs

  • Python
    def A(lastn):
        n,a,chk,nchk=1,[],[],[]
        while n<=lastn:
            i=1
            while i in chk: i+=1
            for x, v in enumerate(chk): chk[x]=v-i
            chk.extend(nchk)
            for x, v in enumerate(nchk): nchk[x]=v+i
            nchk.append(i)
            chk.extend(nchk)
            chk=[x for x in chk if x>0]
            chk=list(set(chk))
            a.append(i)
            print(i)
            n += 1
        return a

A344841 a(n) is the least positive number not of the form a(k) XOR ... XOR a(m) with 1 <= k <= m < n (where XOR denotes the bitwise XOR operator).

Original entry on oeis.org

1, 2, 4, 5, 8, 12, 14, 16, 17, 19, 20, 21, 23, 32, 33, 35, 48, 49, 51, 56, 57, 59, 64, 65, 67, 68, 69, 71, 76, 77, 79, 80, 81, 83, 84, 85, 87, 92, 93, 95, 128, 129, 131, 132, 133, 135, 140, 141, 143, 192, 193, 195, 196, 197, 199, 204, 205, 207, 224, 225, 227
Offset: 1

Views

Author

Rémy Sigrist, May 29 2021

Keywords

Comments

This sequence has similarities with A002048; here we use XOR, there addition.
All powers of 2 appear.

Examples

			  n   a(n)  a(k) XOR ... XOR a(n) for k=1..n
  --  ----  -------------------------------------
   1     1  1
   2     2  3, 2
   3     4  7, 6, 4
   4     5  2, 3, 1, 5
   5     8  10, 11, 9, 13, 8
   6    12  6, 7, 5, 1, 4, 12
   7    14  8, 9, 11, 15, 10, 2, 14
   8    16  24, 25, 27, 31, 26, 18, 30, 16
   9    17  9, 8, 10, 14, 11, 3, 15, 1, 17
  10    19  26, 27, 25, 29, 24, 16, 28, 18, 2, 19
		

Crossrefs

Programs

  • PARI
    s=2^0; for (n=1, #a=vector(61), print1 (a[n]=valuation(s+1, 2)", "); z=0; forstep (k=n, 1, -1, s=bitor(s, 2^z=bitxor(z,a[k]))))
    
  • Python
    from operator import xor
    from itertools import count, accumulate, islice
    from collections import deque
    def A344841_gen(): # generator of terms
        aset, alist = set(), deque()
        for k in count(1):
            if k in aset:
                aset.remove(k)
            else:
                yield k
                aset |= set(k^d for d in accumulate(alist,xor))
                alist.appendleft(k)
    A344841_list = list(islice(A344841_gen(),60)) # Chai Wah Wu, Sep 01 2025

Formula

Apparently, a(A246360(k)) = 2^(k-1) for any k > 0.
Showing 1-10 of 10 results.