Imagine you need to generate "pulsing" sequence of numbers, which should continuously repeat while going up and down between needed values, like this: 5-6-7-8-9-10-9-8-7-6-5-6-7...
Purposes of such sequence may be different, but anyway, we want to have universal solution even for this simple problem. Algorithm is simple too...