I'm trying to find a simple formula for a periodic sequence like this:
$$ 0,1,2,3,4,3,2,1,0...$$
I've figured it out for the increasing part of the sequence by using a modulo operator:
$$ i\ mod \ 5 $$
In that way, I have the desired upper and lower bound and it's periodic. The above formula gives me a sequence:
$$0,1,2,3,4,0,1,2,3...$$
Which is close. What change do I have to make to $$ i\ mod\ 5$$ in order for the sequence to decrease?
Thanks in advance!
How about $4-\mid (i\%8)-4 \mid$. (Here $\%$ is the mod operator.) I think this gives the sequence $0,1,2,3,4,3,2,1,0,1,2,3,4,...$