Finding Pythagorean triplet given the hypotenuse I have a number $c$ which is an integer and can be even or odd. It is the hypotenuse of a right angled triangle. How can I find integers $a,b$ such that
$$ a^2 + b^2 = c^2 $$
What would be the complexity of the calculation?

You can find one or more triples, given only $C$ if $GCD(A,B,C)=2$ or a perfect square, which includes all primitives and such as $(27,36,45)$. You cannot find those that are otherwise, such as $3,5,6,7,8,10$ times  a primitive, e.g. $(45,24,51)=3*(15,8,17)$.
We solve $C=m^2+n^2$ for $n$, and look for positive integers
$$n=\sqrt{C-m^2}\text{ where }{\lceil \sqrt{\frac{C}{2}}\space\rceil\le m\le \lfloor\sqrt{C}\rfloor}$$.
If we want to find one or more triples for $C=145$, then  we have 
$$m_{min}=\lceil \sqrt{\frac{145}{2}}\space\rceil=9\qquad m_{max}=\lfloor\sqrt{145}\rfloor=12$$
If we try $9\le m \le 12$, we find $n\in\mathbb{N}$ only for $\sqrt{145-9^2}=8$ and $\sqrt{145-12^2}=1$
$$f(9,8)=(17,144,145)\qquad f(12,1)=(143,24,145)$$ 
For $C=1105$, there are $4$ triples; for $C=29$, there is $1$ triple; for $C=31$, there are no triples. If $C=20$, we find $f(4,2)=(12,16,20)=2^2*f(2,1)=2^2*(3,4,5)$. Try the numbers and see for yourself.
