I'm trying to define a formula which will assist in the generation of some unusual numeric sequences. The sequences are known ahead of time, so I'm really just looking for a simple arithmetic formula that can be used to calculate them, rather than hard coding the values (so that it's more extensible for future updates to my system). I've tried this a number of ways but am not sure what method to use in order to attempt to define this. Any assistance would be extremely appreciated!
when n = 1 the sequence = [0,2,...]
when n = 2 the sequence = [0,-1,3,2,...]
when n = 3 the sequence = [0,-1,-2,4,3,2,...]
when n = 4 the sequence = [0,-1,-2,-3,5,4,3,2,...]
when n = 6 the sequence = [0,-1,-2,-3,-4,-5,7,6,5,4,3,2,...]
when n = 8 the sequence = [0,-1,-2,-3,-4,-5,-6,-7,9,8,7,6,5,4,3,2,...]
All sequences loop on the "..." (i.e. when n=1 the sequence is really [0,2,0,2,0,2,etc.])
Re-stating the task
The task is to define a formula that defines the value of the ith member of the sequence, with prior-knowledge of the value of n.
aka x in f(n,i) = x
Fwiw, this is a real world problem to assist in the generation of dynamic imposition templates for a printing application :)