자바 스크립트 (ES7), 165 바이트
@NeilA.의 답변 과 마찬가지로 이것은 Tunnell의 정리를 기반으로 하므로 Birch 및 Swinnerton-Dyer 추측이 사실이라고 가정합니다.
부울 값을 반환합니다.
n=>(r=(g=i=>i<n?g(i+!(n%i**2?0:n/=i*i)):n**.5|0)(s=2),g=(C,k=r)=>k+r&&g(C,k-1,C(k*k)))(x=>g(y=>g(z=>s+=2*(n==(X=(n&1?2:8)*x+(o=2-n%2)*y)+o*32*z)-(n==X+o*8*z))))|s==2
온라인으로 사용해보십시오!
방법?
nn′r=⌊n′−−√⌋s2
r = ( // we will eventually save isqrt(n) into r
g = i => // g = recursive function taking an integer i
i < n ? // if i is less than n:
g(i + !( // do a recursive call with either i or i + 1
n % i**2 ? // if n is not divisible by i²:
0 // yield 0 and therefore increment i
: // else:
n /= i * i // divide n by i² and leave i unchanged
)) // end of recursive call
: // else:
n ** .5 | 0 // stop recursion and return isqrt(n)
)(s = 2) // initial call to g with i = s = 2
gCk2−r<k≤r
g = (C, k = r) => // C = callback function, k = counter initialized to r
k + r && // if k is not equal to -r:
g( // do a recursive call:
C, // pass the callback function unchanged
k - 1, // decrement k
C(k * k) // invoke the callback function with k²
) // end of recursive call
g(x,y,z)∈[−r+1,r]3s2An=Bnn2Cn=Dnn
An=#{(x,y,z)∈[−r+1,r]3∣n=2x2+y2+32z2}Bn=#{(x,y,z)∈[−r+1,r]3∣n=2x2+y2+8z2}Cn=#{(x,y,z)∈[−r+1,r]3∣n=8x2+2y2+64z2}Dn=#{(x,y,z)∈[−r+1,r]3∣n=8x2+2y2+16z2}
g(x => // for each x: \ NB:
g(y => // for each y: >-- all these values are
g(z => // for each z: / already squared by g
s += // add to s:
2 * ( // +2 if:
n == ( // n is equal to either
X = // An if n is odd (o = 1)
(n & 1 ? 2 : 8) * x + // or Cn if n is even (o = 2)
(o = 2 - n % 2) * y //
) + o * 32 * z //
) - ( // -1 if:
n == X + o * 8 * z // n is equal to either
) // Bn if n is odd
) // or Dn if n is even
) //
) // if s in unchanged, then n is (assumed to be) congruent