making a color ramp cycle back and forth
Sounds like you want a sine wave! Just multiply your incoming value by sin (with a multiplication node and sine node, respectively) and you'll get your oscillation of 0 to 1 and back again. There's some official documentation on just that use case here: https://docs.blender.org/manual/en/dev/compositing/types/converter/math.html#using-sine-function-to-pulsate

Then, add one 1, and divide the result by 2. This is a much smoother way of interpolating between 0 and 1 while avoiding negatives, as Rich Sedman suggested!

In other words, this set-up should go between your existing "Divide" and "ColorRamp" nodes: