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.

A358537 For n > 0, a(n) is the total number of terms in all contiguous subsequences of the terms up to a(n-1) that sum to n; a(0) = 1.

Original entry on oeis.org

1, 1, 2, 2, 5, 4, 4, 2, 2, 5, 7, 8, 6, 11, 10, 16, 5, 22, 6, 19, 15, 22, 20, 9, 18, 5, 14, 16, 23, 9, 8, 11, 16, 12, 19, 21, 0, 21, 8, 20, 11, 17, 25, 28, 4, 18, 4, 30, 23, 40, 7, 20, 18, 18, 14, 9, 40, 9, 29, 32, 23, 6, 17, 23, 16, 8, 26, 32, 35, 27, 64, 10
Offset: 0

Views

Author

Neal Gersh Tolunsky, Dec 18 2022

Keywords

Examples

			To find a(4), we look at the sequence so far (1, 1, 2, 2) to find contiguous subsequences that sum to 4: (1, 1, 2) and (2, 2). This is five terms in total, so a(4) = 5. Notice that the two subsequences overlap.
a(40) is 11 because the following contiguous subsequences sum to 40: (6, 19, 15); (23, 9, 8); (19, 21); (19, 21, 0). This is a total of 11 terms.
		

Crossrefs

Programs

  • Maple
    N:= 100: V:= Array(0..N):
    V[0]:= 1:
    for n from 0 to N-1 do
      s:= 0;
      for j from n to 0 by -1 do
        s:= s + V[j];
        if s > N then break fi;
        if s > n then V[s]:= V[s] + n-j+1 fi;
      od;
    od:
    convert(V,list); # Robert Israel, Feb 16 2023
  • PARI
    { for (n=1, #a=m=vector(72), print1 (a[n] = if (n==1, 1, m[n-1])", "); s = w = 0; forstep (k=n, 1, -1, w++; if ((s += a[k]) > #m, break, s, m[s] += w))) } \\ Rémy Sigrist, Feb 09 2023

Extensions

Data edited by Yifan Xie, Feb 08 2023
More terms from Rémy Sigrist, Feb 09 2023

A363279 a(0)=1; a(1)=2. For n>1, a(n) is the number of contiguous groups in the sequence thus far whose sum is n.

Original entry on oeis.org

1, 2, 1, 2, 1, 1, 2, 3, 1, 2, 4, 1, 3, 5, 4, 3, 5, 5, 2, 4, 6, 4, 4, 5, 2, 8, 5, 4, 7, 6, 6, 3, 8, 7, 5, 7, 5, 6, 11, 5, 6, 9, 11, 2, 6, 10, 8, 6, 6, 11, 7, 7, 10, 6, 10, 7, 6, 11, 11, 4, 9, 13, 6, 10, 11, 9, 8, 7, 9, 9, 10, 10, 6, 14, 10, 9, 8, 11, 7, 11, 12, 9, 11, 11, 10, 7
Offset: 0

Views

Author

Neal Gersh Tolunsky, May 25 2023

Keywords

Examples

			a(2)=1 because in the sequence thus far (1, 2), there is only one contiguous subsequence that sums to n=2: (2).
a(7)=3 because in the sequence thus far (1, 2, 1, 2, 1, 1, 2), there are three groups of consecutive terms that sum to n=7: (1, 2, 1, 2, 1); (2, 1, 2, 1, 1); (1, 2, 1, 1, 2).
		

Crossrefs

Programs

  • Python
    from collections import Counter
    from itertools import count, islice
    def agen(): # generator of terms
        yield from [1, 2]
        sumsn, c =  [2, 3], Counter([1, 2, 3])
        for n in count(2):
            an = c[n]
            yield an
            sumsn = [an] + [s + an for s in sumsn]
            c.update(sumsn)
    print(list(islice(agen(), 86))) # Michael S. Branicky, May 25 2023
Showing 1-2 of 2 results.