OFFSET
1,4
FORMULA
a(n) = sum_of_transposition_distances(n) (see Maple code given below)
EXAMPLE
Inverses of 1 .. 10 in field Z11 are: 1,6,4,3,9,2,8,7,5,10 (e.g. 9*5 = 45 = 1 mod 11) if we count each inverse's "distance from its own position", we get 0+4+1+1+4+4+1+1+4+0 = 20, divided by 2 is 10, so a(5)=10 (11 is the fifth prime).
MAPLE
with(numtheory); sum_of_transposition_distances := proc(n) local p, i; p := ithprime(n); add(abs(op(2, op(1, msolve(i*x=1, p)))-i), i=1..(p-1))/2; end;
MATHEMATICA
a[n_] := Module[{p = Prime[n], x}, Sum[x - i /. Solve[i*x == 1, Modulus -> p] // First // Abs, {i, 1, p - 1}]/2]; Array[a, 50] (* Jean-François Alcover, Mar 05 2016 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Antti Karttunen, Dec 14 1999
STATUS
approved