Question: If I have the numbers 0 1 2 and 3, how many combinations of any size but maximum of 4 add to a multiple of 4?

EG:
0000 = 0 ( so 0\*4), 

1. 1111 = 4,
2. 0000 = 0 ( so 0\*4),
3. 0112

How many combinations are there?

Answer: 
As this is tagged [homework](/questions/tagged/homework "show questions tagged 'homework'"), I will derive the solution for length $N=4$, which is the hardest part. But the framework is there to apply basically the same argument to any other length.

Treat the elements $\{0,1,2,3\}$ as elements to the group $G=(\mathbb{Z}\_4,+)$.

The question is then "how many way can we pick exactly four elements $a,b,c,d$ from $G$, including the identity, such that $abcd=e$," with $e$ representing the identity.

If $abcd = e$, then $ab = (cd)^{-1}$. Consider $\alpha = ab $ and $\beta = (cd)^{-1}$. This induces the unique choices: $(\alpha,\beta) \in \{(0,0),(1,3),(2,2),(3,1)\}$. We see that the range of $\alpha$ is $G$. Thus, we can apply the argument again to $\alpha = ab$. Hence, for any choice of $\alpha$, there are exactly 4 ways to choose $a,b$ to generate $\alpha$.

Then, for any choice of $\alpha$, the value of $\beta$ is chosen for us. But again, we can choose $c,d$ in 4 different ways to obtain $\beta$.

Hence, there are $4\times 4\times 4 = 4^3 = 64$ ways to add $0,1,2,3$ to get to a multiple of $4$.

---

Some Python code to verify:

```
>>>a=0
>>>for i in range(0,4):
       for j in range(0,4):
           for k in range(0,4):
               for l in range(0,4):
                   s = i+j+k+l
                   if s % 4 == 0:
                       a = a+1
>>> a
64

```
For length $4$. Suppose you already picked the first three. Then there is exactly one number that you can put in the end to make it a multiple of 4. Therefore there are $4^3=64$ such lists.

Using the same method we see the total is $4^0+4^1+4^2+4^3$=$\frac{4^4-1}{4-1}=\frac{255}{3}=85$