Help building an index Hello to all the mathematicians, I'm not a mathematician myself, so my apologies in advance.

I'm writing a program which uses an index that should range between $0-10$. Every iteration I get as an output of one a the following natural numbers: 
  $1,2,3,4$. I want the output to affect the index in a magnitude of it's value, while yet making sure the index doesn't exceed the predefined limits (not less than $0$ and not bigger than $10$).

How can I achieve that? Help would be appreciated.
 A: As said in the comments, you can use modular arithmetic.
Basically, let us call $i$ to the index and $n$ to the output ($1,2,3,4$) :


*

*Define how $i$ is modified by $n$, it depends on you. This is an example, let us suppose that we decide that $i = i + n$. As the sum will eventually greater than $10$, you need to "relocate" any results over $10$ back to the "domain" you want to use, which is the set of integers in the range $[0..10]$.

*For that purpose, it is possible to apply modular arithmetic to make the results remain in the range of desired integers $[0..10]$. Usually all programming languages have a "modulo" operator able to do that. For instance, Python uses "%", so this is an example:

$$i = (i+n)\%11$$

e.g.: if $i+n$ is one of the following values:

$\{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22...\}$

... the value will finally be converted (respectively) to the following one:

$\{0,1,2,3,4,5,6,7,8,9,10,0,1,2,3,4,5,6,7,8,9,10,0...\}$

So in essence, applying modular arithmetic we maintain the domain of the result inside the desired discrete integer values in the range $[0..10]$
