
EXAMPLE

For n=4, there are a(4)=16 permutations without collinear triples: [1, 2, 4, 3], [1, 3, 2, 4], [1, 3, 4, 2], [1, 4, 2, 3], [2, 1, 3, 4], [2, 3, 1, 4], [2, 4, 1, 3], [2, 4, 3, 1], [3, 1, 2, 4], [3, 1, 4, 2], [3, 2, 4, 1], [3, 4, 2, 1], [4, 1, 3, 2], [4, 2, 1, 3], [4, 2, 3, 1], [4, 3, 1, 2]


PROG

(PARI) { a(n) = local(p, r, g); r=0; for(j=1, n!, p=numtoperm(n, j); g=1; forvec(v=vector(3, i, [1, n]), if(matdet([1, v[1], p[v[1]]; 1, v[2], p[v[2]]; 1, v[3], p[v[3]]])%n==0, g=0; break), 2); if(g, r++)); r }
