Is there a way to to express the following without using an if statement, but with mathematical operations instead?
{ 5 if x % 5 = 0, x % 5 otherwise }
You can use the 3rd offset argument of Mod
for this:
Mod[x, 5, 1]
The 3rd argument effectively shifts the point where Mod
loops back. So Mod[x, 5, 0]
loops from 0 to 4 and Mod[x, 5, 1]
loops from 1 to 5.
Mod[x-1,5]+1
? $\endgroup$