How many pythagorean triples are there where one side is given, and is $2^n$? I have checked a table with all the Pythagorean triples (there are 127 of them) and I have counted them (there are 12), but how can I answer this question without counting them individually?
 A: We have 2 cases:
The side is the hypothenuse
This means we have to solve the norm equation for $2^n$ in $\Bbb Z[i]$. As 2 factors as $2=(1+i)^2$ (up to units) it follows that for even exponents: $(2^n)^2=4^n=(1+i)^{4n}$ the right side is always real and therefore there are only degenerate solutions like $2^2=2^2+0^2$.
The side is a cathetus
This means we have to solve $$4^n=c^2-a^2=(c+a)(c-a)=:u\cdot v$$ and thus $c=(u+v)/2$ and $a=(u-v)/2$. As 2 is prime in $\Bbb Z$, $u$ and $v$ must be powers of 2: $u=2^{2n-k}$ and $v=2^k$ with the constraints $0<k<2n-k$ so that the solutions are:
$$c,a=2^{k-1}(4^{n-k} \pm1) $$
For example, for $n=3$ we can have $k=1,2$ and consequently the two triples $(10,8,6)$ and $(17,8,15)$.
The constraint can be rewritten as $0<k<n$, hence we have exactly $n-1$ solutions for a given $n$ (up to order).
And for each $n>1$ there is exactly one primitive solution, namely the one with $k=1$:$$(4^{n-1}+1,2^n,4^{n-1}-1)$$
The other solutions are just multiples from smaller $n$'s. 
