25 lines
333 B
Markdown
25 lines
333 B
Markdown
毕达哥拉斯数可以由如下公式得出
|
||
|
||
$$
|
||
a=2mn \\
|
||
b=m^2-n^2 \\
|
||
c=m^2+n^2
|
||
$$
|
||
显然 $m>n$ ,因此不妨设 $m=n+k$ ,则
|
||
$$
|
||
a=2n^2+2nk \\
|
||
b=k^2+2nk \\
|
||
c=2n^2+2nk+k^2
|
||
$$
|
||
所以 $a+b+c=4n^2+6nk+2k^2$ 。
|
||
|
||
$4n^2+6n+2<N$ ,所以
|
||
$$
|
||
n<\frac{\sqrt{4N+1}-3}{4}
|
||
$$
|
||
$2k^2+6nk+4n^<N$ ,所以
|
||
$$
|
||
k<\frac{\sqrt{2N+n^2}-3n}{2}
|
||
$$
|
||
|