The Maple script below defines a procedure primitives(startdegree,maxdegree,startpoly) that dumps all primitive polynomials modulo two from degree startdegree up to degree maxdegree in the notation of Numerical Recipes as static long arrays in C in the file primitiv.c . The first polynomial to be tested for primitivity in degree startdegree is startpoly. -----------------------------------snip--------------------------------- primitives := proc(startdegree,maxdegree,startpoly) local count, q, topbit, maxpol, j, pol, polynomial, k, l, m, n, file, fd, beginpoly; file := `primitiv.c`; fd := fopen(file,WRITE,TEXT); fprintf(fd,`\n`); fclose(fd); beginpoly := startpoly; count:=0; for q from startdegree to maxdegree do fd := fopen(file,APPEND,TEXT); fprintf(fd,`static long PrimitivePolynomialDegree%d[]={\n`,q); fflush(fd); topbit := 2^q; maxpol := topbit/2-1; for j from beginpoly to maxpol do pol := topbit+j*2+1; polynomial := convert(pol, 'base', 2); polynomial := add(polynomial[-k-1]*x^k,k=0..q); if ( Primitive(polynomial) mod 2 ) then count := count+1; fprintf(fd,`%d,\n`,j); fflush(fd); fi; od; beginpoly := 0; fprintf(fd,` -1 };\n`); fflush(fd); fclose(fd); od; fd := fopen(file,APPEND,TEXT); fprintf(fd,`\n /* Total number of polynomials computed : %d */\n\n`,count); fprintf(fd,`static long *PrimitivePolynomials[]={`); fflush(fd); for q from 1 to maxdegree do fprintf(fd,`\n PrimitivePolynomialDegree%d`,q); if (q