The solution to your problem is pretty straightforward, but Michael is right, you don’t seem to fully grasp what loops can accomplish yet.
In fact, you don’t need to provide all the data beforehand! You simply calculate it iteratively inside the loop, starting at a single or multiple values. At each iteration the loop, performs its task(s) on the result of the previous iteration, if recursion is desired.
For your example, you simply provide the first value, Y(n-1), to the D0 input of the
Loop Start, which is 0. Inside the loop, you need to get offset(n) and lenght(n-1) at each iteration.
lenght(n-1) is quite straightforward, since it’s simply the current iteration count C, incremented by 1 (since the loop count starts at 0).
offset(n) can be provided by a series of even numbers that starts at 0. At each iteration of the loop, you simply get the corresponding even offset with the current iteration count, since the series has a length equal to the number of loop iterations. You don’t have to provide the series to a loop input, since it is constant, meaning that it isn’t iteratively changed by the loop.
All that remains is to add all the values together and forward their sum to the D0 input of the
Loop End component. This value, Y(n-1), will get looped and changed at each iteration. Simply set the
Loop End component to Record Data, which means that it records D0 at each iteration.
success.gh (10.6 KB)