OFFSET
0,4
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..400
L. Li, Collinear triples in permutations, arXiv:0802.0572 [math.CO], 2008.
FORMULA
For n>=3, a(n) = (n-3)! * A146557(n).
EXAMPLE
For example, in a permutation p=[5,2,4,3,1], a triple of points { (2,p(2)=2), (4,p(4)=3), (5,p(5)=1) } is collinear, since they are located on the line: x + 3*y == 3 (mod 5).
MATHEMATICA
f[n_] := n*Sum[ Sum[ (n - i - j)*( n*GCD[i, j, n - i - j] - GCD[i, n] - GCD[j, n] - GCD[i + j, n] + 2 ) , {j, 1, n - i}] , {i, 1, n}]; Join[{0, 0, 0}, Table[(n - 3)!*f[n], {n, 3, 25}]] (* G. C. Greubel, Oct 18 2016 *)
PROG
(PARI) a(n) = if(n<3, 0, (n-3)! * n * sum(i=1, n, sum(j=1, n-i-1, (n-i-j) * (n*gcd([i, j, n-i-j]) - gcd(i, n) - gcd(j, n) - gcd(i+j, n) + 2) )))
CROSSREFS
KEYWORD
nonn
AUTHOR
R. J. Mathar, Feb 22 2008, corrected Oct 24 2008
EXTENSIONS
Edited and extended by Max Alekseyev, Oct 31 2008
STATUS
approved