%I #25 Sep 08 2022 08:45:48
%S 0,0,0,193,1548,6714,21280,55395,125748,257908,489024,870885,1473340,
%T 2388078,3732768,5655559,8339940,12009960,16935808,23439753,31902444,
%U 42769570,56558880,73867563,95379988,121875804,154238400,193463725,240669468,297104598,364159264
%N Number of ways to place 2 nonattacking kings on an n X n X n raumschach board.
%C We consider that kings "attack" any square that differs by at most one in any combination of the indices from its current space. A logical extension of sequence A061995.
%H Andrew Woods, <a href="/A166540/b166540.txt">Table of n, a(n) for n = 0..1000</a>
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Three-dimensional_chess">Three-dimensional chess</a>
%H <a href="/index/Rec#order_07">Index entries for linear recurrences with constant coefficients</a>, signature (7,-21,35,-35,21,-7,1).
%F a(n) = (n^6 - (3*n-2)^3) / 2 = (n^6)/2 - (27*n^3)/2 + 27*n^2 - 18*n + 4 for n>0. - _Andrew Woods_, Aug 30 2011
%F G.f.: x^3*(193 +197*x -69*x^2 +35*x^3 +4*x^4)/(1-x)^7. - _Colin Barker_, Jan 09 2013
%F E.g.f.: (8 -8*x +4*x^2 +63*x^3 +65*x^4 +15*x^5 +x^6)*exp(x)/2 -4. - _G. C. Greubel_, Apr 03 2019
%t LinearRecurrence[{7,-21,35,-35,21,-7,1}, {0, 0, 0, 193, 1548, 6714, 21280, 55395}, 35] (* _G. C. Greubel_, May 16 2016; a(7) appended by _Georg Fischer_, Apr 03 2019 *)
%o (Python) # Two non-attacking kings in n x n x n cubic "board" .
%o m=int(input('What\'s the biggest board to investigate? '))
%o for n in range (0, m+1):
%o sum=0
%o for x1 in range (1, n+1):
%o for y1 in range (1, n+1):
%o for z1 in range (1, n+1):
%o for x2 in range (1, n+1):
%o for y2 in range (1, n+1):
%o for z2 in range (1, n+1):
%o if abs(x1-x2)>1 or abs(y1-y2)>1 or abs(z1-z2)>1:
%o sum=sum+1
%o sum=sum//2
%o print(n, sum)
%o (PARI) {a(n) = if(n==0,0, (n^6 -(3*n-2)^3)/2)}; \\ _G. C. Greubel_, Apr 03 2019
%o (Magma) [0] cat [(n^6 -(3*n-2)^3)/2: n in [1..35]]; // _G. C. Greubel_, Apr 03 2019
%o (Sage) [0]+[(n^6 -(3*n-2)^3)/2 for n in (1..35)] # _G. C. Greubel_, Apr 03 2019
%Y Cf. A061995, A194605.
%K nonn,easy
%O 0,4
%A _Michael Engling_, Oct 16 2009