%I #56 Sep 08 2022 08:46:14
%S 1,6,48,384,240,288,672,6144,1296,1440,2640,18432,4368,4032,11520,
%T 49152,9792,7776,13680,92160,32256,15840,24288,294912,30000,26208,
%U 34992,258048,48720,69120,59520,393216,126720,58752,161280,497664,101232,82080,209664,1474560
%N Number of orthogonal 3 X 3 matrices over the ring Z/nZ.
%C Number of matrices M = [a,b,c; d,e,f; g,h,i] with 0 <= a, b, c, d, e, f, g, h, i < n such that M*transpose(M) == [1,0,0; 0,1,0; 0,0,1] (mod n).
%C For n > 1, a(n) is divisible by 6*A060594(n)^3. - _Robert Israel_, Dec 16 2015
%H Robert Israel, <a href="/A264083/b264083.txt">Table of n, a(n) for n = 1..124</a>
%F For p an odd prime, a(p) = 2*p*(p^2-1). - _Tom Edgar_, Nov 04 2015
%F From _Robert Israel_, Dec 16 2015: (Start)
%F Conjectures:
%F a(2^k) = 12*8^k for k >= 3.
%F For odd primes p, a(p^k) = a(p)*p^(3k-3) for k>=1. (End)
%p F:= proc(n) local R,V,nR,S,nS,Rp,nRp,i,j,a,b,c,t,r,r1,count;
%p R:= select(t -> t[1]^2 + t[2]^2 + t[3]^2 mod n = 1, [seq(seq(seq([a,b,c],a=0..n-1),b=0..n-1),c=0..n-1)]);
%p nR:= nops(R);
%p S:= select(t -> t^2 mod n = 1, {$2..n-1});
%p nS:= nops(S);
%p for r in R do if not assigned(V[r]) then
%p for c in S do V[c*r mod n] := 0 od
%p fi od;
%p R:= select(r -> not assigned(V[r]), R);
%p nR:= nops(R);
%p count:= 0;
%p for i from 1 to nR do
%p r:= R[i];
%p Rp:= select(j -> R[j][1]*r[1] + R[j][2]*r[2] + R[j][3]*r[3] mod n = 0, [$i+1..nR]);
%p nRp:= nops(Rp);
%p for j from 1 to nRp do
%p r1:= R[Rp[j]];
%p count:= count + 6*(1+nS)^3*nops(select(k -> R[Rp[k]][1]*r1[1] + R[Rp[k]][2]*r1[2]+R[Rp[k]][3]*r1[3] mod n = 0, [$j+1..nRp]));
%p od
%p od;
%p count;
%p end proc:
%p F(1):= 1:
%p seq(F(n), n=1..40); # _Robert Israel_, Dec 16 2015
%o (Magma)
%o Enter R := IntegerRing(n);
%o korthmat := function(R,n,k);
%o O := [];
%o M := MatrixAlgebra(R,n);
%o for x in M do
%o if x*Transpose(x) eq k*M!1 and Transpose(x)*x eq k*M!1 then
%o O := Append(O,x);
%o end if;
%o end for;
%o return O;
%o end function;
%o # korthmat(R,3,1);
%o (PARI) my(t=Mod(matid(3), n)); sum(a=1, n, sum(b=1, n, sum(c=1, n, sum(d=1, n, sum(e=1, n, sum(f=1, n, sum(g=1, n, sum(h=1, n, sum(i=1, n, my(M=[a, b, c; d, e, f; g, h, i]); M*M~==t))))))))) \\ _Charles R Greathouse_ IV, Nov 10 2015
%Y Cf. A060594, A087784, A208895.
%K nonn,mult
%O 1,2
%A _Charles Repizo_, Nov 03 2015
%E a(11)-a(31) from _Tom Edgar_, Nov 05 2015
%E a(31) corrected by _Robert Israel_, Dec 15 2015