login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A331614
a(n+1) is the number of times a(n) is the sum of one or more consecutive terms in this sequence so far with a(1) = 1.
8
1, 1, 2, 2, 3, 2, 4, 3, 3, 4, 4, 5, 4, 6, 4, 7, 5, 5, 6, 5, 7, 6, 6, 7, 7, 8, 3, 5, 8, 5, 9, 7, 9, 8, 6, 8, 7, 10, 7, 11, 8, 8, 9, 9, 10, 8, 10, 9, 11, 9, 12, 6, 9, 13, 8, 11, 10, 10, 11, 11, 12, 7, 12, 8, 12, 9, 14, 10, 12, 10, 13, 9, 15, 7, 13, 10, 14, 11, 13, 11, 14, 12, 11, 15
OFFSET
1,3
LINKS
Samuel B. Reid, Density plot of one billion terms. This plot is normalized by column.
EXAMPLE
For example we look for the next 2 terms after a(7) = 4:
The sequence so far: 1, 1, 2, 2, 3, 2, 4.
We count how many times we can sum up consecutive terms to get 4 as result (and include all 4's already in the sequence).
There are 3 ways to get a sum of 4: 1 + 1 + 2, 2 + 2 and 4. This gives us a(8) = 3.
For the next term we count all sums of 3 we can get: 1 + 2, 3, 3. This means there are 3 ways and a(9) = 3.
MATHEMATICA
a[1] = 1; a[n_] := a[n] = Block[{c = 0, j, s}, Do[j = i; s = 0; While[j < n && s < a[n - 1], s += a[j]; j++]; If[s == a[n - 1], c++], {i, n - 1}]; c]; Array[a, 84] (* Giovanni Resta, Jan 23 2020 *)
(* Second program needing version >= 10.1 *)
a[n_] := a[n] = If[n == 1, 1, SequenceCount[Array[a, n-1], s_ /; Total[s] == a[n-1], Overlaps -> True]];
Array[a, 100] (* Jean-François Alcover, Feb 15 2020 *)
PROG
(Excel)
Cell A1: 1
Cell A2: =countif(A$1:AZ1; A1)
Cell B2: =if(A1=""; ""; A1+$A2)
Copy B2 and paste into area B2:AZ2
Copy row 2 and paste down (5000 lines worked, more could be slow)
(PARI) for (n=1, #a=vector(#t=vector(84)), print1 (a[n]=if(n==1, 1, t[a[n-1]])", "); s=0; forstep (k=n, 1, -1, if (#t<s+=a[k], break, t[s]++))) \\ Rémy Sigrist, Feb 14 2020
CROSSREFS
Cf. A332518.
Sequence in context: A355270 A066241 A334857 * A343541 A060025 A368572
KEYWORD
nonn
AUTHOR
S. Brunner, Jan 22 2020
STATUS
approved