Number of Pythagorean triplets How can I find the number of Pythagorean triplets $(a, b, c)$ such that:
$1\le a \le b \le c \le N$,
$
a, b, c, N  \in  \mathbb {N}
$
$
1 \le N\le10^6
$
 A: I doubt there is a simple closed form for this quantity. There is an exact formula
$$
\sum_{n\ge1} \sum_{\substack{m>n \\ \gcd(m,n)=1 \\ m\not\equiv n\pmod 2}} \bigg\lfloor \frac N{m^2+n^2} \bigg\rfloor,
$$
which follows from classical formulas generating all Pythagorean triples. Methods of analytic number theory can estimate this asymptotically; I believe it is about $(N\log N)/(2\pi)$ in size when $N$ is large.
A: The number of primitive Pythagorean triples for $A\le N$ is over $50\%$ because there are one-or-more triples for every odd number greater than one. As $A$ increases, the chance of having more than one [primitive] triple with the same side increases, e.g.
$$(15,8,17)\quad (15,112,113)\quad (21,20,29)\quad (21,220,221)\quad (33,56,65)\\ (33,544,545)\quad (35,12,37)\quad (35,612,613)\quad (39,80,89)\quad (39,760,761)\\ (45,28,53)\qquad (45,1012,1013)\qquad (51,140,149)\qquad (51,1300,1301)$$
If you wanted to consider all Pythagorean triple then the number of them are greater than $N$ because, for example with $N=100$ there are well more than $100$ triples, about $170$ by my estimate.
$(3,4,5),\space (6,8,20),\cdots,(96,40,104),\space (96,110,146),\space 
 (96,280,296),\space(96,1150,1154)$
By the way, half of all Pythagorean triples have $A<B$ as I confirmed in my recent question here.
