OFFSET
1,4
COMMENTS
Conjecture: this sequence is defined. That is, each a(n-1) appears as a partial sum starting from some offset.
EXAMPLE
For n=3 (the first term after the initial conditions), we are looking for a run that sums to a(2) = 1 (and doesn't include a(2)). The most recent such run starts at a(1) = 1, and goes for one place. So a(3) = 2, the distance from a(n-1) to the beginning of the run.
For n=4, we are looking for a run that sums to 2. The last such run is a(1) + a(2) + a(3), at a distance of 3 away. so a(4) = 3.
PROG
(Haskell)
findSumRun target index runLength sum (x:xs)
| sum == target = index + runLength
| runLength == 0 = findSumRun target index 1 x (x:xs)
| sum > target = findSumRun target (index+1) (runLength-1) (sum-x) xs
| sum < target = findSumRun target index (runLength+1) (sum + ((x:xs)!!(runLength))) (x:xs)
step (x:xs) = findSumRun x 0 0 0 xs
seq 0 xs = xs
seq n xs = ves (n-1) ((step xs):xs)
CROSSREFS
KEYWORD
nonn
AUTHOR
Ethan Goldberg, Sep 06 2020
STATUS
approved