(*Mathematica 8.0.1*) (*start*) (*The program generates the first nn=160 terms of A006530*) nn = 160; Monitor[Table[ 1 + n - Sum[ Sum[N@Cos[-2*Pi*k/n*Product[j^n, {j, 1, m}]]/n, {m, 1, n}], {k, 1, n}], {n, 1, nn}], n] Round[%] (*end*)