# combinatorics – How to generate all combinations

There is $$N$$ optimization variables, $$v_1, v_2, cdots, v_N$$.
and $$v_n in {0,1,2,3, cdots, K}$$.

Let $$N = 10$$ and $$K = 5$$.

How can I generate all possible combinations?

For example, the first combination is $$[0hspace{1mm} 0hspace{1mm} 0hspace{1mm} 0hspace{1mm} 0hspace{1mm} 0hspace{1mm} 0hspace{1mm} 0hspace{1mm} 0hspace{1mm} 0]$$

The last combination is $$[5hspace{1mm} 5hspace{1mm} 5hspace{1mm} 5hspace{1mm} 5hspace{1mm} 5hspace{1mm} 5hspace{1mm} 5hspace{1mm} 5hspace{1mm} 5]$$