A166540 Number of ways to place 2 nonattacking kings on an n X n X n raumschach board.
0, 0, 0, 193, 1548, 6714, 21280, 55395, 125748, 257908, 489024, 870885, 1473340, 2388078, 3732768, 5655559, 8339940, 12009960, 16935808, 23439753, 31902444, 42769570, 56558880, 73867563, 95379988, 121875804, 154238400, 193463725, 240669468, 297104598, 364159264
Offset: 0
Links
- Andrew Woods, Table of n, a(n) for n = 0..1000
- Wikipedia, Three-dimensional chess
- Index entries for linear recurrences with constant coefficients, signature (7,-21,35,-35,21,-7,1).
Programs
-
Magma
[0] cat [(n^6 -(3*n-2)^3)/2: n in [1..35]]; // G. C. Greubel, Apr 03 2019
-
Mathematica
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 *)
-
PARI
{a(n) = if(n==0,0, (n^6 -(3*n-2)^3)/2)}; \\ G. C. Greubel, Apr 03 2019
-
Python
# Two non-attacking kings in n x n x n cubic "board" . m=int(input('What\'s the biggest board to investigate? ')) for n in range (0, m+1): sum=0 for x1 in range (1, n+1): for y1 in range (1, n+1): for z1 in range (1, n+1): for x2 in range (1, n+1): for y2 in range (1, n+1): for z2 in range (1, n+1): if abs(x1-x2)>1 or abs(y1-y2)>1 or abs(z1-z2)>1: sum=sum+1 sum=sum//2 print(n, sum)
-
Sage
[0]+[(n^6 -(3*n-2)^3)/2 for n in (1..35)] # G. C. Greubel, Apr 03 2019
Formula
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
G.f.: x^3*(193 +197*x -69*x^2 +35*x^3 +4*x^4)/(1-x)^7. - Colin Barker, Jan 09 2013
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
Comments