Got it! Thank you for your patience…
I tried to extend the code for 3, 5, 7, 9, 3, 5, 7, 9, but on the second repeat I get 4, 6, 8…
int[] testsequence;
// first parameter is number of repetitions
// second parameter is lo
// third parameter is hi
// fourth parameter is interval
void setup() {
testsequence = series_function(2, 3, 9, 2);
//println(testsequence);
exit();
}
int[] series_function(int n, int lo, int hi, int skip) {
int qty = abs(hi - lo) + 1;
int len = abs(n) * qty;
int dir;
if (hi >= lo) {
dir = 1;
} else {
dir = -1;
}
int seq[] = new int[len];
for (int i = 0; i < len; i += skip) {
seq[i] = i % qty * dir + lo;
println(seq[i]); // here during testing
}
return seq;
}