# In how many ways can a number be expressed as a sum of squares of two natural numbers? [duplicate]

This question already has an answer here:

In how many ways can $145^2$ be expressed as sum of two squares?

I tried solving it by finding out the Pythagoren triplets. $145= m^2+n^2 = 12^2+1^2$ & $9^2+8^2$ so triplet is $(145, m^2-n^2 , 2mn) = (145,143,24)=29*(5,4,3)$ & $(145,17,144)$ & one will come from $29$.. i.e $5*(29,21,20)$ total triplets 4. $(145,143,24)$ , $(145,17,144)$ , $(145,116,87)$ & $(145 , 105,100)$. Is there any easier way of doing this?