What is the number of positive integer solutions $(a, b)$ to $2016 + a^2 = b^2$?
We have,
$2016 = (b-a)(b+a) = 2^5 \cdot 3^2 \cdot 7$
$b - a = 2^{t_1} 3^{t_2} 7^{t_4}$ and
$a - b = 2^{t_5} 3^{t_6} 7^{t_7}$
Thus, we must have $t_1 + t_5 = 5$ and $t_2 + t_6 = 2$ and $t_4 + t_7 = 1$.
Total, $\binom{6}{1} \cdot\binom{3}{1} \cdot\binom{2}{1} = 36$.
But the actual answer is $12$, where am I going wrong?
First of all, $a$ and $b$ must be integers. Since $$ a = \frac{(b+a) - (b-a)}{2},\quad b = \frac{(b+a) + (b-a)}{2} $$ we see that for $a$ and $b$ to be integers, $(b-a)$ and $(b+a)$ must have the same parity. Since at least one of them must be even (there are five powers of $2$ to distribute between them), then both must be even. Therefore, instead of $0\leq t_1, t_5 \leq 6$, we have $1\leq t_1, t_5\leq 5$. Therefore we get $4\cdot 3 \cdot 2 = 24$ possible combinations.
Next, exactly half of the distributions makes $b-a > b+a$, which is not allowed (since there is an odd number of $2$'s and $7$'s, none of the distributions make $b-a = b+a$). Therefore only half of the $24$ combinations from the previous paragraph are actually valid. Thus we get $12$ combinations in total.