%I #9 Mar 05 2016 04:23:49
%S 0,0,1,4,10,25,33,46,58,97,130,247,243,310,312,417,444,729,738,654,
%T 1007,836,968,1095,1623,1603,1720,1652,1997,2143,2872,2786,3123,2920,
%U 3069,3534,4103,4654,4130,4933,4434,5355,5576,6959,5915,5788,7440,7994
%N Sum of transposition distances (divided by 2) present in the permutation produced by inverses of 1..(p-1) computed in Zp, where p is n-th prime.
%F a(n) = sum_of_transposition_distances(n) (see Maple code given below)
%e 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).
%p 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;
%t 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 *)
%K nonn
%O 1,4
%A _Antti Karttunen_, Dec 14 1999