Hello everyone
I am working on a function in which neighbouring integers of a sequence are subtracted from one another. As a rule, the smaller number is subtracted from the larger one so that there are no negative values. This process continues until there are no values left.
I am encountering two problems:
1.
I have to create a separate file for each new sequence because the process is cyclical. By this I mean that the last element of a sequence is brought into a subtractive process with the first element. Therefore, I have to write a function for a series with 7 numbers, with 8 numbers, with 9 numbers, etc. What I would like, ideally, is to have a single function into which I can input anything from 2 to a maximum of 30 numbers and which will always “react cyclically”, that is, no matter the amount of inputted numbers, the last value will always refer back to the first value.
2.
The second problem is the more complex one.
When two neighbouring numbers are subtracted, sooner or later the result will be zero. If this happens, I would like the cell to be blank. Now, the important thing is that in the next “round” of subtractions this blank cell is “jumped over” (ignored) in favour of the next occurring number. In this way, ‘0’ (zero) is never involved in the actual process of subtraction but only positive integers. The process will then exhaust itself and come to a close.
I have attached a file that illustrates this much better than my verbal explanation.
On the left hand side is my own version which is “wrong” since zeros are included and the process is potentially infinite or on a loop.
On the right-hand side is a manual reproduction of the same 10-number sequence demonstrating how I would envisage the results (and the function) to be.
Can anyone help?
Bookmarks