About counting number of n-tuples Let n-tuples be $(x_1,x_2,x_3,...x_n)$ and $0\le x_i<q$ ($x_i$ is integers) for $i=1,2,3,...,n$.
First part of the question was about the number of n-tuples. I got this part right, (number of n-tuples)$=q^n$
But for the second part, it is asking the number of n-tuples considering the order of the n-tuples does not matter anymore. For example, (0,0,1,5) and (1,0,0,5) are considered as the same thing.
So, I am thinking as picking $n$ numbers in range of $0\le x_i<q$ because the order does not matter. So, the answer that I got is $\frac {q!} {n!(q-n)!}$.
Is this right??
 A: This can be done using the Polya Enumeration Theorem. Here the group is the symmetric group $S_n$ on $n$ elements and we seek to evaluate the substituted cycle index
$$Z(S_n)(Y_1+Y_2+\cdots+Y_q)_{Y_1=Y_2=\cdots=Y_q=1}.$$
The recurrence for the cycle index of $S_n$ is
$$Z(S_n) = \frac{1}{n} \sum_{l=1}^n a_l Z(S_{n-l}).$$
Let the substituted cycle index be $Q_n.$
The recurrence then becomes
$$Q_n = \frac{1}{n} \sum_{l=1}^n (Y_1^l+Y_2^l+\cdots+Y_q^l) Q_{n-l}
= q \frac{1}{n} \sum_{l=1}^n Q_{n-l}.$$
The convention is that $Z(S_0)=1$ and hence also $Q_0 = 1.$ Introduce the generating function $$Q(z) = \sum_{n\ge 0} Q_n z^n.$$
Rewrite the recurrence as
$$n Q_n = q  \sum_{l=1}^n Q_{n-l}$$
and multiply by $z^{n-1}$ and sum over $n\ge 1:$
$$\sum_{n\ge 1} n Q_n z^{n-1} = Q'(z) = q \sum_{n\ge 1} z^{n-1}   \sum_{l=1}^n Q_{n-l}
= q  \sum_{n\ge 1} z^{n-1} [z^{n-1}] \frac{1}{1-z} Q(z). $$
This yields
$$Q'(z) = q  \frac{1}{1-z} Q(z).$$
Solving the DE produces
$$ Q(z) = C \frac{1}{(z-1)^q}.$$
But we must have $Q_0 = 1$ for all $q$ so $C = (-1)^q$ and therefore
$$ Q(z) = \frac{1}{(1-z)^q}.$$
It follows that
$$Q_n = [z^n] Q(z) = [z^n]  \frac{1}{(1-z)^q} = {n+q-1\choose q-1}.$$
We recognize the stars-and-bars method from this link.
