Map sequence of integers into repeating sequence
<p>I have a continuous, ordered sequence of integers that start less than zero and go above zero; for instance <code>...,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7</code>. I need to map these into a repeating sequence <code>3,6,9,12</code>, with the initial condition that <code>f(0)=3</code>. So for instance <code>f(-2)=9, f(-1)=12, f(0)=3, f(1)=6, f(2)=9, f(3)=12, f(4)=3</code> and so on. Is there a compact way to express this operation in Java, so that we are able to just use the remainder (%) operator and avoid any if/else statements?</p>
