Vince DieselСпасибо.
Текущий код:
Код:
Manipulate[
 f[x_, y_] := (
   If[x == 1 && y == 1, Return[a11]];
   If[x == 1 && y == 2, Return[a12]]; 
   If[x == 1 && y == 3, Return[a13]]; 
   If[x == 1 && y == 4, Return[a14]]; 
   If[x == 1 && y == 5, Return[a15]]; 
   If[x == 2 && y == 1, Return[a21]]; 
   If[x == 3 && y == 1, Return[a31]]; 
   If[x == 4 && y == 1, Return[a41]]; 
   If[x == 5 && y == 1, Return[a51]];
   If[x == 1 && 5 < y < 9, Return[f[1, 1] + f[1, 5] - f[1, y - 4]]];
   If[y == 1 && 5 < x < 9, Return[f[1, 1] + f[5, 1] - f[x - 4, 1]]];
   If[1 < x < 9 && 1 < y < 9, Return[f[x, y - 1] + f[x - 1, y] - f[x - 1, y - 1]]]
   );
 U = Table[, {64}];
 For[i = 1, i < 9, i++, 
  For[j = 1, j < 9, j++, If[PrimeQ[T[[i, j]]], V = Blue, V = Red]; 
   U[[j + 8 (i - 1)]] = {i, j} -> V]];
 T = Table[f[i, j], {i, 8}, {j, 8}];
 S = 0; For[k = 1, k < 9, k++, S = S + T[[k, k]]];
 Grid[{{, 
    Grid[Table[Sum[T[[i, j]], {8}], {i, 1}, {j, 8}], Frame -> All, 
     FrameStyle -> Gray, ItemSize -> All, 
     Spacings -> {2, 2}],}, {Grid[
     Table[Sum[T[[i, j]], {8}], {i, 8}, {j, 1}], Frame -> All, 
     FrameStyle -> Gray, ItemSize -> All, Spacings -> {2, 2}], 
    Grid[T, Frame -> All, ItemSize -> All, Spacings -> {2, 2}, 
     ItemStyle -> {Automatic, Automatic, U}, 
     Background -> {None, None, {{{1, 5}, {1, 1}} -> LightYellow, {{1, 1}, {1, 5}} -> LightYellow}}], 
    Grid[Table[S, {8}, {1}], Frame -> All, FrameStyle -> Gray, 
     ItemSize -> All, Spacings -> {2, 2}]}, {, 
    Grid[Table[S, {1}, {8}], Frame -> All, FrameStyle -> Gray, 
     ItemSize -> All, Spacings -> {2, 2}],}}],
 {{a11, 3, "A(1,1)"}, 1, 10000, 1, Appearance -> "Open"},
 {{a12, 3, "A(1,2)"}, 1, 10000, 1, Appearance -> "Open"}, {{a13, 3, "A(1,3)"}, 1, 10000, 1, Appearance -> "Open"},
 {{a14, 3, "A(1,4)"}, 1, 10000, 1, Appearance -> "Open"}, {{a15, 3, "A(1,5)"}, 1, 10000, 1, Appearance -> "Open"},
 {{a21, 3, "A(2,1)"}, 1, 10000, 1, Appearance -> "Open"}, {{a31, 3, "A(3,1)"}, 1, 10000, 1, Appearance -> "Open"},
 {{a41, 3, "A(4,1)"}, 1, 10000, 1, Appearance -> "Open"}, {{a51, 3, "A(5,1)"}, 1, 10000, 1, Appearance -> "Open"},
 ControlPlacement -> Left, ContinuousAction -> None]