TITLE: How to simplyfy the expression ${(m+k-1 \text{ mod } k) + 1}$?
QUESTION [1 upvotes]: $m$ takes values from 1 to an even number $M$ and $k = M/2$. This expression ${(m+k-1 \text{ mod } k) + 1}$ gives the repeated sequence of numbers from 1 to k. How can I further simply the expression to give the same repeated sequence?
For example M = 24 the expression gives the sequence
1     2     3     4     5     6     7     8     9    10    11    12     1     2     3     4     5     6     7     8     9    10    11    12

REPLY [0 votes]: Obviously $k\equiv0\bmod k$, so in the end we get $(m-1)\bmod k+1$ (assuming the computing definition of $\bmod$).
{"set_name": "stack_exchange", "score": 1, "question_id": 3978327}