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