OFFSET
1,3
LINKS
Rémy Sigrist, Table of n, a(n) for n = 1..10000
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
KEYWORD
nonn
AUTHOR
S. Brunner, Jan 22 2020
STATUS
approved