For a positive integer $n$, denote $A_n=\{(x,y)\in\mathbb Z^2|x^2+xy+y^2=n\}$.

(a) Prove that the set $A_n$ is always finite.
(b) Prove that the number of elements of $A_n$ is divisible by $6$ for all $n$.
(c) For which $n$ is the number of elements of $A_n$ divisible by $12$?
### Part (a)
1. Consider the equation \( x^2 + xy + y^2 = n \).
2. Rewrite it as a quadratic equation in \( x \): \( x^2 + xy + y^2 - n = 0 \).
3. The discriminant of this quadratic equation in \( x \) must be a perfect square for \( x \) to be an integer. The discriminant is given by:
   \[
   \Delta = y^2 - 4(y^2 - n) = y^2 - 4y^2 + 4n = -3y^2 + 4n
   \]
4. For \( x \) to be an integer, \( \Delta \) must be a perfect square, say \( m^2 \). Thus, we have:
   \[
   m^2 = 4n - 3y^2
   \]
5. Rearrange to get:
   \[
   4n = m^2 + 3y^2
   \]
6. Since \( n \) is a positive integer, there are only finitely many integer pairs \((m, y)\) that satisfy this equation because \( m^2 + 3y^2 \) must be a multiple of 4 and less than or equal to \( 4n \).
7. For each valid \( y \), there are at most 2 corresponding values of \( x \) (since the quadratic equation in \( x \) can have at most 2 solutions).
8. Therefore, the set \( A_n \) is finite.

\(\blacksquare\)

### Part (b)
1. Consider the set \( A_n = \{(x, y) \in \mathbb{Z}^2 \mid x^2 + xy + y^2 = n\} \).
2. Note that if \( (x, y) \in A_n \), then \( (y, x) \in A_n \) because the equation is symmetric in \( x \) and \( y \).
3. Also, if \( (x, y) \in A_n \), then \( (-x-y, y) \in A_n \) because:
   \[
   (-x-y)^2 + (-x-y)y + y^2 = x^2 + xy + y^2 = n
   \]
4. Similarly, if \( (x, y) \in A_n \), then \( (x, -x-y) \in A_n \) because:
   \[
   x^2 + x(-x-y) + (-x-y)^2 = x^2 - x^2 - xy + x^2 + 2xy + y^2 = x^2 + xy + y^2 = n
   \]
5. These transformations generate 6 distinct pairs from any given pair \((x, y)\) in \( A_n \):
   \[
   (x, y), (y, x), (-x-y, y), (y, -x-y), (-x-y, -x), (-x, -x-y)
   \]
6. Therefore, the number of elements in \( A_n \) is divisible by 6.

\(\blacksquare\)

### Part (c)
1. For the number of elements of \( A_n \) to be divisible by 12, each of the 6 transformations must generate distinct pairs, and there must be an additional symmetry or structure that doubles the count.
2. Consider the equation \( x^2 + xy + y^2 = n \) modulo 3. The possible values of \( x^2 + xy + y^2 \) modulo 3 are 0, 1, or 2.
3. If \( n \equiv 0 \pmod{3} \), then the equation \( x^2 + xy + y^2 \equiv 0 \pmod{3} \) has more solutions because the quadratic form \( x^2 + xy + y^2 \) is symmetric and covers all residues modulo 3.
4. Therefore, for \( n \equiv 0 \pmod{3} \), the number of solutions is higher and divisible by 12.

\(\boxed{n \equiv 0 \pmod{3}} \)