|
- aX[n_] :=
- If[n < 1, 0,
- 1 + Sum[MoebiusMu[d]^2 n/d/12 - EulerPhi[GCD[d, n/d]]/2, {d,
- Divisors@n}] -
- Count[(#^2 - # + 1)/n & /@ Range[n], _?IntegerQ]/3 -
- Count[(#^2 + 1)/n & /@ Range[n], _?IntegerQ]/4];
- data = Table[aX[n], {n, 1, 105}];
- (*创建两列表格,第一列是编号(从0开始),第二列是数据*)
- table = Transpose[{Range[1, Length[data]], data}];
- (*定义样式函数:值为1的行蓝色背景,值为2的行黄色背景*)
- styleFunction[row_] :=
- If[row[[2]] == 1, {Item[row[[1]], Background -> None],
- Item[row[[2]], Background -> LightBlue]},
- If[row[[2]] == 2, {Item[row[[1]], Background -> None],
- Item[row[[2]], Background -> Yellow]}, row (*其他情况不变*)]];
- (*应用样式并添加表头*)
- styledTable = styleFunction /@ table;
- fullTable =
- Prepend[styledTable,
- Item[#, Background -> LightGray] & /@ {"编号", "值"}];
- (*显示表格*)
- Grid[fullTable, Frame -> All, Spacings -> {1, 1} (*调整单元格间距*)]
Copy the Code |
|