Probability that $x^2+y^2$ is a perfect square If two numbers $x$ and $y$ are chosen at random without any replacement(s) from $S=\{{0,1,2,3.....,189}\}$, then what is the probability that $x^2+ y^2$ is a perfect square?
I noticed that if $x=0$,then the number is a perfect square for all $y$. Hence 189 perfect squares are there. By trial and error, I could also figure out that $(4,5)$,$(6,8)$ are some other perfect squares. But I  could not find out all of them.
 A: A fundamental Pythagorean triplet $(x,y,z)$ has $\gcd (x,y)=1.$ Every Pythagorean triplet is of the form $(kx,ky,kz)$ where $(x,y,z)$ is fundamental and $k \in \mathbb N.$ When $(x,y,z)$ is fundamental then $$\bullet \;\{x,y\}=\{2mn, m^2-n^2\}$$ where $m,n$ are co-prime members of $\mathbb N,$ with $m>n$ and with exactly one of $m,n$ odd and the other one even. 
If we can find all fundamental triplets $(x,y,z)$ with $\max (x,y)\leq 189,$ then  then for each one, the non-fundamental triplets in the required range are of the form $(kx,ky,kz)$ for $2\leq k$ and $189\geq k\cdot \max (x,y).$
To find fundamental triplets with $\max (x,y)\leq 189$ : Referring to $\bullet $, consider that $2mn\leq 189\implies mn\leq 94.$ Now $n^2+n=n(n+1)\leq nm\leq 94$ so $$n\leq 9.$$ But we also require $m^2-n^2\leq 189.$ So $m^2-9^2\leq m^2-n^2\leq 189,$ implying $m\leq 270. $ Hence $$m\leq 16.$$ Altogether we have now $n<m\leq 16$ with $n\leq 9,$ with $\gcd (m,n)=1,$ and with $m$ odd and $n$ even, OR $m$ even and $n$ odd. Thus the values of $m,n$ are among the following: $$m\in \{10,12,14,16\}, n\in \{1,3,5,7,9\}.$$ $$ m=8,n\in \{1,3,5,7\}.$$ $$ m=6, n\in \{1,5\}.$$ $$ m=4, n\in \{1,3\}.$$ $$m=2,n=1.$$ $$ m\in \{9,11,13,15\}, n\in \{2,4,6,8\}.$$   $$ m=7, n\in \{2,4,6\}.$$ $$ m=5, n\in \{2,4\}.$$ $$ m=3,n=2.$$ Not all of the above pairs will give  fundamental triplets in the required range. Some of them give $m^2-n^2>189$ or $2mn>189,$ and some of them are (e.g. $m=14,n=7$) are not co-prime pairs. So some of the above pairs must be removed.  This is a matter of some elementary arithmetic. (In particular all the cases with $m=16$ are to be removed, for if $n\leq 7$ then $ 16^2-n^2>189,$ and if $n=9$ then $2mn=2\cdot 16\cdot 9>189.$)
A: Hey I'm no number theorist, but I'm pretty sure you are looking for solutions to the equation 
$x^2 + y^2 = z^2$.  Look familiar? You need Pythagorean triplets such that $x,y \leq 189$. 
Hope this can get you started. 
A: Hint:
You can use this, Pythagorean triples are in the form of:
$$(m^2-n^2, 2mn, m^2+n^2)$$  
Given $m>n$.
Hope you can take it form here. 
Its basic combinatorics with a little bit of logic.  
