Compute mod $1..n$ instead of $0..n-1$

34 Views Asked by At

Here's an example of what I mean for mod 3: $1 => 1$, $2 => 2$, $3 => 3$, $4 => 1$ and so forth. This is for computer programming and while obviously I can easily calculate this I am simply curious whether it's possible without comparisons.

1

There are 1 best solutions below

0
On BEST ANSWER

$$1 + ((n - 1) \mod 3)$$

I need more characters so here they are.