PowerMod[11,-1,15]

PowerMod[51,-1,100]

PowerMod[1,-1,7]

lst=Select[Range[10^7-2],CoprimeQ[#,10^7]&]

i[n_]:=Module[{lst=Select[Range[n-2],CoprimeQ[#,n]&]},Max@Pick[lst, Map[PowerMod[#,-1,n]==#&,lst],True]]

i[100]

i[15]

Sum[i[n],{n,3,40}]

Sum[n,{n,1,3}]

Table[i[n],{n,1,100}]

PowerMod[51,-1,100]

ModularInverse[51,100]

i[999]

Mod[51^2,100]

Mod[11^2,15]

(1/x)*x